Coverage.py is a tool for measuring code coverage of Python programs, currently at version 7.13.5, released on March 17, 2026. It is actively maintained with regular updates addressing various issues and enhancements.
pip install coverageVerified import paths — ran on the pinned version, not inferred.
Basic usage of Coverage.py to measure code coverage and generate an HTML report.
Upgrade to version 7.11.3 or later to restore previous behavior.
Upgrade to version 7.11.2 or later to resolve this issue.
Ensure that the target code is executed when coverage is active and that data collection and saving are configured correctly. Verify the execution environment and paths. Consult the 'coverage.py' documentation on 'No data collected' for detailed troubleshooting.
Ensure that Python code intended for coverage measurement is executed under `coverage.py`'s control (e.g., using `coverage run <your_script.py>`) and that coverage data is saved before attempting to report it (e.g., `coverage combine`, `coverage html`). Verify that the executed script actually runs the relevant code.
Review your `coverage run` command and configuration file (`.coveragerc`): ensure `--source` or `[run] source` correctly points to the directories containing your code, add `__init__.py` files to your directories if they are Python packages, and check for conflicts where other tools might be overriding `sys.settrace`.
Run coverage using `python -m coverage run` to ensure it uses the same Python interpreter and its associated environment as your regular script execution. Additionally, ensure your project's root or relevant paths are correctly added to `PYTHONPATH` or specified via `coverage run --source`.
After running `coverage run` with `parallel=True` (or similar parallel execution setup), you need to combine the individual `.coverage.*` data files into a single `.coverage` file using `coverage combine` before running `coverage report` or `coverage html`.
Adjust the `[run] source` setting in `.coveragerc` to prevent measurement of code outside your project. Alternatively, use `[report] omit` to explicitly skip reporting on temporary directories (e.g., `omit=$TMPDIR/*`), or set `[report] ignore_errors = true` to treat the error as a warning.