File: test_mpi.py

package info (click to toggle)
python-ase 3.21.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,936 kB
  • sloc: python: 122,428; xml: 946; makefile: 111; javascript: 47
file content (23 lines) | stat: -rw-r--r-- 662 bytes parent folder | download | duplicates (2)
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)