File: test_imports.py

package info (click to toggle)
python-ase 3.26.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,484 kB
  • sloc: python: 148,112; xml: 2,728; makefile: 110; javascript: 47
file content (24 lines) | stat: -rw-r--r-- 744 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Check that plain cli doesn't execute too many imports."""

import sys

from ase.utils.checkimports import check_imports


def test_imports():
    forbidden_modules = [
        'gpaw',  # external
        'scipy',  # large
        'ase.io.formats',  # possibly slow external formats
        'ase.calculators.(?!names).*',  # any calculator
    ]
    if sys.version_info >= (3, 10):
        max_nonstdlib_module_count = 350  # this depends on the environment
        # Should get this to less than 200
    else:
        max_nonstdlib_module_count = None
    check_imports(
        'from ase.cli.main import main; main(args=[])',
        forbidden_modules=forbidden_modules,
        max_nonstdlib_module_count=max_nonstdlib_module_count,
    )