forked from duartegroup/autodE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_import.py
32 lines (23 loc) · 940 Bytes
/
test_import.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Tests for the import speed of autode."""
import sys
import pytest
SLOW_IMPORTS = ["matplotlib"]
@pytest.fixture
def unimport_slow_imports():
"""Remove modules in ``SLOW_IMPORTS`` from ``sys.modules``."""
for module in SLOW_IMPORTS:
if module in sys.modules:
del sys.modules[module]
@pytest.mark.usefixtures("unimport_slow_imports")
def test_slow_imports_during_tab_completion():
"""Check that importing autode does not import certain python modules that would make import slow."""
# Let's double check that the undesired imports are not already loaded
for modulename in SLOW_IMPORTS:
assert (
modulename not in sys.modules
), f"Module `{modulename}` was not properly unloaded"
import autode
for modulename in SLOW_IMPORTS:
assert (
modulename not in sys.modules
), f"Detected loaded module {modulename} after autode import"