Skip to content
Latchkey

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.

coverage output
/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.

pyproject.toml / Terminal
[tool.coverage.run]
source = ["src/mypkg"]
parallel = true

# run
coverage run -m pytest && coverage combine && coverage report

Enable subprocess/xdist coverage

  1. Use pytest-cov (which wires subprocess coverage) or set COVERAGE_PROCESS_START.
  2. With xdist, enable parallel = true and coverage combine after the run.
  3. Confirm a .coverage file is produced before reporting.

How to prevent it

  • Set source to the package the tests import, not a different copy.
  • Use pytest-cov or configure subprocess coverage for spawned processes.
  • Run coverage combine when measuring in parallel.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →