Skip to content

Commit acbce79

Browse files
Update tests to improve coverage (#45)
1 parent bfcaec2 commit acbce79

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

.github/workflows/coverage.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
report:
11-
runs-on: ubuntu-22.04
11+
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
1414
python-version: ["3.10"]
@@ -23,6 +23,8 @@ jobs:
2323
run: |
2424
python -m pip install --upgrade pip wheel setuptools
2525
python -m pip install ".[test]"
26+
python -m pip install --upgrade numpy
27+
python -m pip uninstall --yes scipy
2628
pip list
2729
2830
- name: Measure test coverage

lazy_loader/tests/test_lazy_loader.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,16 @@ def test_lazy_import_impact_on_sys_modules():
4949

5050

5151
def test_lazy_import_nonbuiltins():
52-
sp = lazy.load("scipy")
5352
np = lazy.load("numpy")
53+
sp = lazy.load("scipy")
54+
if not isinstance(np, lazy.DelayedImportErrorModule):
55+
assert np.sin(np.pi) == pytest.approx(0, 1e-6)
5456
if isinstance(sp, lazy.DelayedImportErrorModule):
5557
try:
5658
sp.pi
5759
assert False
5860
except ModuleNotFoundError:
5961
pass
60-
elif isinstance(np, lazy.DelayedImportErrorModule):
61-
try:
62-
np.sin(np.pi)
63-
assert False
64-
except ModuleNotFoundError:
65-
pass
66-
else:
67-
assert np.sin(sp.pi) == pytest.approx(0, 1e-6)
6862

6963

7064
def test_lazy_attach():

0 commit comments

Comments
 (0)