Skip to content

Commit eeb6a7d

Browse files
Measure test coverage (#23)
* Measure test coverage * Fix
1 parent b08a4b9 commit eeb6a7d

File tree

7 files changed

+37
-4
lines changed

7 files changed

+37
-4
lines changed

.github/workflows/coverage.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: coverage
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
report:
11+
runs-on: ubuntu-22.04
12+
strategy:
13+
matrix:
14+
python-version: ["3.10"]
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v3
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
22+
- name: Install packages
23+
run: |
24+
python -m pip install --upgrade pip wheel setuptools
25+
python -m pip install ".[test]"
26+
pip list
27+
28+
- name: Measure test coverage
29+
run: |
30+
python -m pytest --cov=lazy_loader --durations=10
31+
# Tests fail if using `--doctest-modules`. I.e.,
32+
# python -m pytest --cov=lazy_loader --doctest-modules --durations=20
33+
codecov

lazy_loader/tests/__init__.py

Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/test_lazy_loader.py renamed to lazy_loader/tests/test_lazy_loader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ def test_lazy_attach():
9797

9898

9999
def test_attach_same_module_and_attr_name():
100-
import fake_pkg
100+
from lazy_loader.tests import fake_pkg
101101

102102
# Grab attribute twice, to ensure that importing it does not
103103
# override function by module
104104
assert isinstance(fake_pkg.some_func, types.FunctionType)
105105
assert isinstance(fake_pkg.some_func, types.FunctionType)
106106

107107
# Ensure imports from submodule still work
108-
from fake_pkg.some_func import some_func
108+
from lazy_loader.tests.fake_pkg.some_func import some_func
109109

110110
assert isinstance(some_func, types.FunctionType)
111111

@@ -126,7 +126,7 @@ def test_stub_loading(tmp_path):
126126

127127

128128
def test_stub_loading_parity():
129-
import fake_pkg
129+
from lazy_loader.tests import fake_pkg
130130

131131
from_stub = lazy.attach_stub(fake_pkg.__name__, fake_pkg.__file__)
132132
stub_getter, stub_dir, stub_all = from_stub

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ dynamic = ["description"]
2121

2222

2323
[project.optional-dependencies]
24-
test = ["pytest >= 7"]
24+
test = ["pytest >= 7.1", "pytest-cov >= 3.0", "codecov >= 2.1"]
2525
lint = ["pre-commit >= 2.20"]
2626

2727
[project.urls]

0 commit comments

Comments
 (0)