coverage.py "No data to report" / "No data was collected" in CI
coverage.py finished but found nothing to report. Either it measured a different source than the code that ran, the code executed in an unmeasured subprocess, or no .coverage data file was produced.
What this error means
coverage report/coverage xml prints No data to report. or a CoverageWarning: No data was collected., often a 0% report or a failing coverage gate, even though tests ran and passed.
/venv/lib/python3.12/site-packages/coverage/control.py:892:
CoverageWarning: No data was collected. (no-data-collected)
No data to report.Common causes
Source path does not match the code that ran
A --source/source= set to the wrong package, or measuring installed site-packages while tests imported a different copy, means coverage recorded nothing for the reported source.
Code ran in an unmeasured subprocess
Tests that spawn subprocesses (or use xdist) need subprocess coverage configured; otherwise the child’s execution is not recorded and the parent has no data.
How to fix it
Point coverage at the source that actually runs
Set the source to your package and run via the coverage-aware invocation.
[tool.coverage.run]
source = ["src/mypkg"]
parallel = true
# run
coverage run -m pytest && coverage combine && coverage reportEnable subprocess/xdist coverage
- Use
pytest-cov(which wires subprocess coverage) or setCOVERAGE_PROCESS_START. - With xdist, enable
parallel = trueandcoverage combineafter the run. - Confirm a
.coveragefile is produced before reporting.
How to prevent it
- Set
sourceto the package the tests import, not a different copy. - Use
pytest-covor configure subprocess coverage for spawned processes. - Run
coverage combinewhen measuring in parallel.