Skip to content

Commit 6b44981

Browse files
committed
Update tests to improve coverage
1 parent bfcaec2 commit 6b44981

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
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 scipy
27+
python -m pip uninstall --yes pandas
2628
pip list
2729
2830
- name: Measure test coverage

lazy_loader/tests/test_lazy_loader.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,29 @@ 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")
54-
if isinstance(sp, lazy.DelayedImportErrorModule):
53+
sp = lazy.load("scipy")
54+
pd = lazy.load("pandas")
55+
if isinstance(np, lazy.DelayedImportErrorModule):
5556
try:
56-
sp.pi
57+
np.sin(np.pi)
5758
assert False
5859
except ModuleNotFoundError:
5960
pass
60-
elif isinstance(np, lazy.DelayedImportErrorModule):
61+
elif isinstance(sp, lazy.DelayedImportErrorModule):
6162
try:
62-
np.sin(np.pi)
63+
sp.pi
6364
assert False
6465
except ModuleNotFoundError:
6566
pass
6667
else:
6768
assert np.sin(sp.pi) == pytest.approx(0, 1e-6)
69+
if isinstance(pd, lazy.DelayedImportErrorModule):
70+
try:
71+
pd.DataFrame()
72+
assert False
73+
except ModuleNotFoundError:
74+
pass
6875

6976

7077
def test_lazy_attach():

0 commit comments

Comments
 (0)