Coverage.py is a free tool for measuring which parts of a Python program run and which executable code is missed. It helps people assess how thoroughly tests exercise a program. Statement coverage is measured by default, with branch coverage also available. Reports can be produced as text, HTML, XML, LCOV, or JSON, and dynamic contexts can associate executed lines with the test function that ran them. Test suites can run through their usual command; pytest-cov is also available, though the documentation says most users do not need it. Third-party plugins can extend measurement to non-Python files, such as connecting executed Python to Django templates. Coverage data is stored in SQLite, and advanced users can work with the Coverage.py API. The documented interpreters include Python 3.10 through 3.15 rc2 and PyPy3 3.10 and 3.11. It offers ctrace and pytrace cores, plus sysmon, which is faster for simple line and branch coverage but lacks support for dynamic contexts and plugins. Coverage.py is licensed under Apache 2.0 and supports Linux, macOS, Windows, and self-hosting.
Who it is for
Coverage.py suits Python developers who want to see which code their tests cover and where they leave gaps. It also fits teams that need multiple report formats or coverage data tied to individual test functions.
What is good
- Free plan and Apache 2.0 license
- Measures statement and branch coverage
- Produces five report formats
- Dynamic contexts link lines to test functions
- Plugins can extend measurement beyond Python
What to know first
- sysmon does not support dynamic contexts
- sysmon does not support plugins
Verdict
Coverage.py provides several ways to measure and report Python test coverage, including optional branch coverage and test-specific contexts. Its sysmon core has narrower capabilities, so users needing contexts or plugins should note that limitation.
Coverage.py plans and pricing
All plansCompared on test coverage tools
- Free plan
- Yes
- Coverage types
- statement, branch
- Supported languages
- Python
- Report formats
- text, HTML, XML, LCOV, JSON
- Self-hosted option
- Yes
- Coverage gates
- Yes
