You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If pytest runs in e.g. ./tests/, it reads ../pyproject.toml for configuration options, and that squares with my expectation. pytest-cov does seem to look only for ./pyproject.toml (and also writes ./.coverage instead of keeping that file at the project root), and that causes it to run with different settings depending on where pytest is invoked.
If I run pytest from the project root directory, I get 100% coverage. If I run it from the tests/ subdirectory, all __repr__ functions, which I don't test, get reports as uncovered.
Reproduced on current master (0ad139c): [tool.coverage.report] exclude_also is honoured when pytest runs from the project root (100%) but ignored when run from tests/ (the excluded def __repr__ shows as missing, 80%). The cause is that coverage.py resolves its config relative to the cwd while pytest's rootdir is the project root. I'll look at how --cov-config / the coverage config file is resolved.
Activity
DawnofGenX commentedon Oct 6, 2026
/take
Reproduced on current master (0ad139c):
[tool.coverage.report] exclude_alsois honoured when pytest runs from the project root (100%) but ignored when run fromtests/(the excludeddef __repr__shows as missing, 80%). The cause is that coverage.py resolves its config relative to the cwd while pytest's rootdir is the project root. I'll look at how--cov-config/ the coverage config file is resolved.fix: resolve coverage config relative to pytest's rootdir (pytest-dev…
fix: resolve coverage config relative to pytest's rootdir (#692)
ci: bump the python-tooling group across 1 directory with 13 updates (#…