Skip to content

Switch to src layout, move tests to root #151

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 6 commits into from
May 17, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
include CHANGELOG.md
include .spin/cmds.py
recursive-include tests *

global-exclude *~
global-exclude *.pyc

prune */.pytest_cache
prune */__pycache__
14 changes: 12 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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]
Expand Down Expand Up @@ -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",
]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ 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
assert isinstance(fake_pkg.some_func, types.FunctionType)
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)

Expand All @@ -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
Expand Down