Skip to content

Measure test coverage #23

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 2 commits into from
Aug 27, 2022
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
33 changes: 33 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: coverage

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
report:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install packages
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install ".[test]"
pip list

- name: Measure test coverage
run: |
python -m pytest --cov=lazy_loader --durations=10
# Tests fail if using `--doctest-modules`. I.e.,
# python -m pytest --cov=lazy_loader --doctest-modules --durations=20
codecov
Empty file added lazy_loader/tests/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ def test_lazy_attach():


def test_attach_same_module_and_attr_name():
import fake_pkg
from lazy_loader.tests import fake_pkg

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

# Ensure imports from submodule still work
from fake_pkg.some_func import some_func
from lazy_loader.tests.fake_pkg.some_func import some_func

assert isinstance(some_func, types.FunctionType)

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


def test_stub_loading_parity():
import fake_pkg
from lazy_loader.tests import fake_pkg

from_stub = lazy.attach_stub(fake_pkg.__name__, fake_pkg.__file__)
stub_getter, stub_dir, stub_all = from_stub
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dynamic = ["description"]


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

[project.urls]
Expand Down