File tree Expand file tree Collapse file tree 1 file changed +9
-19
lines changed Expand file tree Collapse file tree 1 file changed +9
-19
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,15 @@ def test_import_error():
21
21
import anything_not_real # noqa: F401
22
22
23
23
24
+ def test_import_nonbuiltins ():
25
+ pytest .importorskip ("numpy" )
26
+
27
+ with lazy_import ():
28
+ import numpy as np
29
+
30
+ assert np .sin (np .pi ) == pytest .approx (0 , 1e-6 )
31
+
32
+
24
33
def test_builtin_is_in_sys_modules ():
25
34
with lazy_import ():
26
35
import math
@@ -49,25 +58,6 @@ def test_non_builtin_is_in_sys_modules():
49
58
assert "numpy" in sys .modules
50
59
51
60
52
- def test_lazy_import_nonbuiltins ():
53
- sp = lazy .load ("scipy" )
54
- np = lazy .load ("numpy" )
55
- if isinstance (sp , lazy .DelayedImportErrorModule ):
56
- try :
57
- sp .pi
58
- assert False
59
- except ModuleNotFoundError :
60
- pass
61
- elif isinstance (np , lazy .DelayedImportErrorModule ):
62
- try :
63
- np .sin (np .pi )
64
- assert False
65
- except ModuleNotFoundError :
66
- pass
67
- else :
68
- assert np .sin (sp .pi ) == pytest .approx (0 , 1e-6 )
69
-
70
-
71
61
def test_lazy_attach ():
72
62
name = "mymod"
73
63
submods = ["mysubmodule" , "anothersubmodule" ]
You can’t perform that action at this time.
0 commit comments