Skip to content

Update tests to improve coverage #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
report:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
Expand All @@ -23,6 +23,8 @@ jobs:
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install ".[test]"
python -m pip install --upgrade numpy
python -m pip uninstall --yes scipy
pip list

- name: Measure test coverage
Expand Down
12 changes: 3 additions & 9 deletions lazy_loader/tests/test_lazy_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,16 @@ def test_lazy_import_impact_on_sys_modules():


def test_lazy_import_nonbuiltins():
sp = lazy.load("scipy")
np = lazy.load("numpy")
sp = lazy.load("scipy")
if not isinstance(np, lazy.DelayedImportErrorModule):
assert np.sin(np.pi) == pytest.approx(0, 1e-6)
if isinstance(sp, lazy.DelayedImportErrorModule):
try:
sp.pi
assert False
except ModuleNotFoundError:
pass
elif isinstance(np, lazy.DelayedImportErrorModule):
try:
np.sin(np.pi)
assert False
except ModuleNotFoundError:
pass
else:
assert np.sin(sp.pi) == pytest.approx(0, 1e-6)


def test_lazy_attach():
Expand Down