Skip to content

Commit c793e79

Browse files
committed
Update non-builtin test
1 parent beeb504 commit c793e79

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

tests/test_lazy_loader.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ def test_import_error():
2121
import anything_not_real # noqa: F401
2222

2323

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+
2433
def test_builtin_is_in_sys_modules():
2534
with lazy_import():
2635
import math
@@ -49,25 +58,6 @@ def test_non_builtin_is_in_sys_modules():
4958
assert "numpy" in sys.modules
5059

5160

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-
7161
def test_lazy_attach():
7262
name = "mymod"
7363
submods = ["mysubmodule", "anothersubmodule"]

0 commit comments

Comments
 (0)