1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
import sys
from subprocess import run
def test_mpi_unused_on_import():
"""Try to import all ASE modules and check that ase.parallel.world has not
been used. We want to delay use of world until after MPI4PY has been
imported.
We run the test in a subprocess so that we have a clean Python interpreter."""
# Should cover most of ASE:
modules = ['ase.optimize',
'ase.db',
'ase.gui']
imports = 'import ' + ', '.join(modules)
run([sys.executable,
'-c',
'{imports}; from ase.parallel import world; assert world.comm is None'
.format(imports=imports)],
check=True)
|