- Home
- Test Coverage Tools
- Coverage.py
Coverage.py
What it is
Coverage.py measures which parts of Python programs ran and identifies executable code that did not, helping developers gauge which code their tests exercise. It measures statement coverage by default and can also track branch coverage. Reports are available in text, HTML, XML, LCOV, and JSON formats. Dynamic contexts can associate executed lines with the test function that ran them. Coverage.py can run test suites through their usual command; pytest-cov is available as a plugin, though the documentation says it is unnecessary for most purposes. Third-party plugins can extend measurement to non-Python files, such as linking executed Python code to Django templates. Data is stored in a SQLite database, and advanced users can work through the Coverage.py API. The documented interpreter versions include Python 3.10 through 3.15 rc2, including free-threading, and PyPy3 3.10 and 3.11. Its ctrace and pytrace cores are joined by a sysmon core, which is faster for simple line and branch coverage but does not support dynamic contexts or plugins. Coverage.py is Apache 2.0 licensed and runs on Linux, macOS, and Windows, with self-hosting available. It costs nothing.
For and against
For
- Measures statement and branch coverage.
- Produces five report formats.
- Dynamic contexts link lines to test functions.
- Free, Apache 2.0-licensed software.
Against
- Sysmon does not support dynamic contexts or plugins.
- Third-party plugins are needed to measure non-Python files.
The verdict
Coverage.py provides several ways to measure and report Python test coverage, with optional contexts, plugins, and API access. Choose a tracing core with care if dynamic contexts or plugin support is needed.
Who it suits
Coverage.py is suited to Python developers who want to see which code their tests execute and which code remains uncovered. Its report formats and API may also suit teams that need coverage data in different workflows.
Plans and prices
Free
Python code coverage · command-line and API use · local reports
Read 15 Oct 2026 · sourceforge.net
Coverage.py
Open-source Python coverage tool · Enterprise subscription available through Tidelift
Read 3 Oct 2026 · coverage.readthedocs.io
On the record
- Branch coverage
- The tool can measure whether alternative branch paths were executed.coverage.readthedocs.io · read 15 Oct 2026
- C extension
- A C extension is recommended for speed and is required for concurrency and plugin features; Linux builds may need development headers and GCC.coverage.readthedocs.io · read 15 Oct 2026
- Configuration
- Settings can live in .coveragerc, TOML, setup.cfg, tox.ini, or pyproject.toml files.coverage.readthedocs.io · read 15 Oct 2026
- Contexts
- Dynamic contexts can record which test function ran which lines of code.coverage.readthedocs.io · read 3 Oct 2026
- Coverage data API
- `CoverageData` provides a supported interface for reading collected coverage data.coverage.readthedocs.io · read 15 Oct 2026
- Coverage types
- It measures statement coverage by default and can also measure branch coverage.coverage.readthedocs.io · read 3 Oct 2026
- Database format
- Collected results are stored in a SQLite database, whose schema is documented as advanced and subject to change.coverage.readthedocs.io · read 15 Oct 2026
- Documentation and support
- Help is offered through extensive Read the Docs material, Python forums, Python Discord, GitHub issues, and optional Tidelift support.coverage.readthedocs.io · read 15 Oct 2026
- Extensibility
- Third-party plugins can extend measurement to non-Python files, such as mapping executed Python back to Django HTML templates.coverage.readthedocs.io · read 3 Oct 2026
- Installation
- The documented installation command is `python3 -m pip install coverage`.coverage.readthedocs.io · read 15 Oct 2026
- Integrations
- Official examples cover pytest, unittest, and nose, and pytest commonly uses the pytest-cov plugin.coverage.readthedocs.io · read 15 Oct 2026
- Intended users
- The documentation presents Coverage.py as a tool for people measuring Python test effectiveness by seeing which code tests exercise and which they miss.coverage.readthedocs.io · read 3 Oct 2026
- Licence
- The package is distributed under the Apache 2.0 licence.pypi.org · read 15 Oct 2026
- License
- Coverage.py is licensed under the Apache 2.0 License.github.com · read 3 Oct 2026
- Limit: default test distinction
- ClickUp notes that Coverage.py does not automatically distinguish test code from the application code being tested.clickup.com · read 15 Oct 2026
- Limit: dynamic execution
- Hysen Labs cautions that dynamically generated code using exec or eval may not be captured accurately.hysenlabs.com · read 15 Oct 2026
- Limit: language scope
- Independent reviews identify Python as the supported product language, limiting use for multi-language coverage programs.hysenlabs.com · read 15 Oct 2026
- Limit: measured performance
- A 2023 arXiv study measured median overhead of 180% on CPython and 1,300% on PyPy for coverage.py.arxiv.org · read 15 Oct 2026