diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 2898e39..da3a31e 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -31,7 +31,7 @@ jobs: 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 + # python -m pytest --cov=src --durations=10 --doctest-modules - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 diff --git a/MANIFEST.in b/MANIFEST.in index fc49293..ce1d4c7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,9 @@ include CHANGELOG.md +include .spin/cmds.py +recursive-include tests * + +global-exclude *~ +global-exclude *.pyc + +prune */.pytest_cache +prune */__pycache__ diff --git a/pyproject.toml b/pyproject.toml index 36bd7a5..ba778f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ dependencies = [ ] [project.optional-dependencies] -test = ["pytest >= 8.0", "pytest-cov >= 5.0"] +test = ["pytest >= 8.0", "pytest-cov >= 5.0", "coverage[toml] >= 7.2"] lint = ["pre-commit == 4.2.0"] dev = ["changelist == 0.5"] @@ -48,7 +48,7 @@ log_cli_level = "info" [tool.ruff] exclude = [ - "lazy_loader/tests/fake_pkg/__init__.pyi", + "tests/fake_pkg/__init__.pyi", ] [tool.ruff.lint] @@ -92,3 +92,13 @@ ignore = [ [tool.ruff.format] docstring-code-format = true + +[tool.coverage.run] +branch = true +source = ["lazy_loader", "tests"] + +[tool.coverage.paths] +source = [ + "src/lazy_loader", + "*/site-packages/lazy_loader", +] diff --git a/lazy_loader/__init__.py b/src/lazy_loader/__init__.py similarity index 100% rename from lazy_loader/__init__.py rename to src/lazy_loader/__init__.py diff --git a/lazy_loader/tests/__init__.py b/tests/__init__.py similarity index 100% rename from lazy_loader/tests/__init__.py rename to tests/__init__.py diff --git a/lazy_loader/tests/fake_pkg/__init__.py b/tests/fake_pkg/__init__.py similarity index 100% rename from lazy_loader/tests/fake_pkg/__init__.py rename to tests/fake_pkg/__init__.py diff --git a/lazy_loader/tests/fake_pkg/__init__.pyi b/tests/fake_pkg/__init__.pyi similarity index 100% rename from lazy_loader/tests/fake_pkg/__init__.pyi rename to tests/fake_pkg/__init__.pyi diff --git a/lazy_loader/tests/fake_pkg/some_func.py b/tests/fake_pkg/some_func.py similarity index 100% rename from lazy_loader/tests/fake_pkg/some_func.py rename to tests/fake_pkg/some_func.py diff --git a/lazy_loader/tests/import_np_parallel.py b/tests/import_np_parallel.py similarity index 100% rename from lazy_loader/tests/import_np_parallel.py rename to tests/import_np_parallel.py diff --git a/lazy_loader/tests/test_lazy_loader.py b/tests/test_lazy_loader.py similarity index 97% rename from lazy_loader/tests/test_lazy_loader.py rename to tests/test_lazy_loader.py index 9fcc783..e0d0221 100644 --- a/lazy_loader/tests/test_lazy_loader.py +++ b/tests/test_lazy_loader.py @@ -128,7 +128,7 @@ def test_lazy_attach_returns_copies(): def test_attach_same_module_and_attr_name(): - from lazy_loader.tests import fake_pkg + from tests import fake_pkg # Grab attribute twice, to ensure that importing it does not # override function by module @@ -136,7 +136,7 @@ def test_attach_same_module_and_attr_name(): assert isinstance(fake_pkg.some_func, types.FunctionType) # Ensure imports from submodule still work - from lazy_loader.tests.fake_pkg.some_func import some_func + from tests.fake_pkg.some_func import some_func assert isinstance(some_func, types.FunctionType) @@ -157,7 +157,7 @@ def test_stub_loading(tmp_path): def test_stub_loading_parity(): - from lazy_loader.tests import fake_pkg + from tests import fake_pkg from_stub = lazy.attach_stub(fake_pkg.__name__, fake_pkg.__file__) stub_getter, stub_dir, stub_all = from_stub