-
Notifications
You must be signed in to change notification settings - Fork 228
Description
Over at Mesa we encountered a strange issue:
pytest-cov stopped collecting coverage data after reorganizing tests from a flat package structure into nested subdirectories even though the test discovery and execution worked perfectly. See mesa/mesa#2994 for the exact changes (only test file renames).
I tried about everything, but couldn't get it fixed with pytest-cov. Switching to coverage fixed it immediately (so we did that for now mesa/mesa#3005). I still would like to get to the root cause. Below some details.
What happens:
- All 379 tests are discovered ✅
- All 379 tests run successfully ✅
- pytest-cov reports: "No data was collected. (no-data-collected)" ❌
- coverage.py itself shows the warning, suggesting it ran but didn't trace anything
Environment:
- pytest-cov 7.0.0
- coverage 7.13.0
- Python 3.14.2
- pytest 9.0.2
Workaround:
Usingcoverage run -m pytestinstead ofpytest --covworks correctly
and reports 82% coverage as expected.Configuration:
[tool.coverage.run] source = ["mesa"] branch = true omit = ["tests/*"] relative_files = trueQuestions:
- Is this a known limitation of pytest-cov with nested test packages?
- Should pytest-cov detect this and provide a clearer error message?
- Is there a configuration option we're missing that would make this work?
The cryptic "no data collected" error gave no hints about what changed or
how to fix it. Given that test reorganization into subdirectories is a
common refactoring, better diagnostics would be valuable.