File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -21,18 +21,25 @@ def test_import_error():
21
21
import anything_not_real # noqa: F401
22
22
23
23
24
- def test_lazy_import_impact_on_sys_modules ():
25
- math = lazy .load ("math" )
26
- anything_not_real = lazy .load ("anything_not_real" )
24
+ def test_builtin_is_in_sys_modules ():
25
+ with lazy_import ():
26
+ import math
27
+
28
+ assert isinstance (math , types .ModuleType )
29
+ assert "math" in sys .modules
30
+
31
+ math .pi # trigger load of math
27
32
28
33
assert isinstance (math , types .ModuleType )
29
34
assert "math" in sys .modules
30
- assert isinstance (anything_not_real , lazy .DelayedImportErrorModule )
31
- assert "anything_not_real" not in sys .modules
32
35
36
+
37
+ def test_non_builtin_is_in_sys_modules ():
33
38
# only do this if numpy is installed
34
39
pytest .importorskip ("numpy" )
35
- np = lazy .load ("numpy" )
40
+ with lazy_import ():
41
+ import numpy as np
42
+
36
43
assert isinstance (np , types .ModuleType )
37
44
assert "numpy" in sys .modules
38
45
You can’t perform that action at this time.
0 commit comments