Skip to content

Commit 44c7010

Browse files
effigiesstefanv
andauthored
Switch to src layout, move tests to root (#151)
* Switch to src layout, move tests to root * Add tests to MANIFEST.in * chore: Configure coverage * Only track coverage for lazy-loader, not tests * Review MANIFEST.in * Try setting coverage to package name --------- Co-authored-by: Stefan van der Walt <[email protected]>
1 parent 024e49f commit 44c7010

File tree

10 files changed

+24
-6
lines changed

10 files changed

+24
-6
lines changed

.github/workflows/coverage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
run: |
3232
python -m pytest --cov=lazy_loader --durations=10
3333
# Tests fail if using `--doctest-modules`. I.e.,
34-
# python -m pytest --cov=lazy_loader --doctest-modules --durations=20
34+
# python -m pytest --cov=src --durations=10 --doctest-modules
3535
3636
- name: Upload coverage to Codecov
3737
uses: codecov/codecov-action@v5

MANIFEST.in

+8
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
include CHANGELOG.md
2+
include .spin/cmds.py
3+
recursive-include tests *
4+
5+
global-exclude *~
6+
global-exclude *.pyc
7+
8+
prune */.pytest_cache
9+
prune */__pycache__

pyproject.toml

+12-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies = [
2525
]
2626

2727
[project.optional-dependencies]
28-
test = ["pytest >= 8.0", "pytest-cov >= 5.0"]
28+
test = ["pytest >= 8.0", "pytest-cov >= 5.0", "coverage[toml] >= 7.2"]
2929
lint = ["pre-commit == 4.2.0"]
3030
dev = ["changelist == 0.5"]
3131

@@ -48,7 +48,7 @@ log_cli_level = "info"
4848

4949
[tool.ruff]
5050
exclude = [
51-
"lazy_loader/tests/fake_pkg/__init__.pyi",
51+
"tests/fake_pkg/__init__.pyi",
5252
]
5353

5454
[tool.ruff.lint]
@@ -92,3 +92,13 @@ ignore = [
9292

9393
[tool.ruff.format]
9494
docstring-code-format = true
95+
96+
[tool.coverage.run]
97+
branch = true
98+
source = ["lazy_loader", "tests"]
99+
100+
[tool.coverage.paths]
101+
source = [
102+
"src/lazy_loader",
103+
"*/site-packages/lazy_loader",
104+
]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ def test_lazy_attach_returns_copies():
128128

129129

130130
def test_attach_same_module_and_attr_name():
131-
from lazy_loader.tests import fake_pkg
131+
from tests import fake_pkg
132132

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

138138
# Ensure imports from submodule still work
139-
from lazy_loader.tests.fake_pkg.some_func import some_func
139+
from tests.fake_pkg.some_func import some_func
140140

141141
assert isinstance(some_func, types.FunctionType)
142142

@@ -157,7 +157,7 @@ def test_stub_loading(tmp_path):
157157

158158

159159
def test_stub_loading_parity():
160-
from lazy_loader.tests import fake_pkg
160+
from tests import fake_pkg
161161

162162
from_stub = lazy.attach_stub(fake_pkg.__name__, fake_pkg.__file__)
163163
stub_getter, stub_dir, stub_all = from_stub

0 commit comments

Comments
 (0)