Freedom251 › Test Coverage Tools
Coverage.py

What Coverage.py is
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 suits
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 it does well
- 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
Plans
| Plan | Billed and limits | Price |
|---|---|---|
| Coverage.py | Open-source Python coverage tool · Enterprise subscription available through Tidelift | Free |
| Free | Free · Python code coverage · command-line and API use · local reports | Free |
As coverage.readthedocs.io lists them, read 3 Oct 2026. The maker's own page has the final word.
Getting started
- Visit https://coverage.readthedocs.io/.
- Use Coverage.py with a documented Python or PyPy3 interpreter.
- Run your test suite through its usual command.
- Choose statement coverage by default or enable branch coverage.
- Generate a text, HTML, XML, LCOV, or JSON report.
Coverage.py is a free coverage measurement tool for Python developers who want to see which executable code their tests reach. It is a strong fit for teams that need flexible reports or test-specific coverage without changing how they run test suites. Its faster sysmon core is best for straightforward line and branch measurement, not workflows that depend on contexts or plugins.
Overview
Coverage.py records which parts of a Python program run and identifies executable code that did not run. Statement coverage is the default; branch coverage adds a view of whether alternative paths have been exercised. These measures can expose gaps in test reach, but coverage alone does not show whether tests verify behavior effectively.
The tool can run a test suite through its usual command, making it suitable for existing Python test workflows. The pytest-cov plugin is available, though the project says most users do not need it. Coverage data is stored in SQLite, and the API supports more advanced uses. Coverage.py is licensed under Apache 2.0.
Key features
Measurement, contexts, and reports
Coverage.py produces text, HTML, XML, LCOV, and JSON reports. That range suits both direct inspection and workflows that consume structured output. Dynamic contexts can identify which test function ran particular lines, helping teams investigate coverage at test level instead of relying only on an aggregate result.
There are three measurement cores: ctrace, pytrace, and sysmon. Sysmon is faster for basic line and branch coverage, but it does not support dynamic contexts or plugins. Teams that need to associate lines with tests or extend measurement to other file types should use a compatible core rather than trade those capabilities for sysmon's speed.
Extensibility and compatibility
Third-party plugins can extend measurement to non-Python files, including mapping executed Python back to Django HTML templates. This is useful when a Python application renders templates and teams want coverage beyond Python source; it also means plugin-dependent workflows cannot use sysmon.
The current documentation lists Python 3.10 through 3.15 rc2, including free-threading, and PyPy3 versions 3.10 and 3.11. That interpreter range gives teams options across standard Python and PyPy environments, including a release candidate. Coverage.py supports Python, and its stated platforms include API, Linux, macOS, self-hosted deployments, and Windows.
Pricing
| Plan | Price | What it includes |
|---|---|---|
| Coverage.py | free | Open-source Python coverage tool; enterprise subscription available through Tidelift. |
The free plan is the tool itself, making it a suitable choice for individual developers and teams seeking Python coverage without a software charge. Enterprise support is available through a Tidelift Subscription; it is a separate route for organizations that want professional support rather than a different core coverage feature set.
Platforms
Coverage.py is listed for Linux, macOS, and Windows, and supports self-hosted use. The API is also a supported platform category. This suits teams running coverage in their own development or test environments rather than requiring a hosted service.
Who it's for
Coverage.py is for Python developers and teams evaluating which code their tests exercise. It is particularly well suited to projects that benefit from branch coverage, multiple report formats, test-specific contexts, or plugins for non-Python files. Teams focused on simple line and branch reports may prefer sysmon's speed; those requiring contexts or plugins should avoid that core.
Pros and cons
Pros
- Statement and optional branch coverage help teams examine both executed lines and conditional paths.
- Five report formats accommodate readable output and structured downstream use.
- Dynamic contexts connect executed lines to test functions, making test-level investigation possible.
- Third-party plugins can extend measurement to files such as Django templates.
- The free, Apache 2.0-licensed tool stores data in SQLite and offers an API for advanced use.
Cons
- Sysmon does not support dynamic contexts or plugins, so speed comes at a cost for those workflows.
- Coverage measures code execution, not whether tests meaningfully check the behavior they exercise.
- Professional support is a separate Tidelift Subscription rather than part of the free tool.
Alternatives
For other options, see the Test Coverage Tools directory.
- OpenClover is another free option, with Linux, macOS, web, and Windows platforms and no license tiers, keys, or usage limits stated for its free plan.
- SimpleCov is a free, MIT-licensed Ruby code coverage tool, making it the relevant choice for Ruby rather than Python projects.
- Coveralls offers a free option for open-source and public repositories, so it may suit teams seeking coverage reporting for those projects.
- Coverlet is a free option for modern .NET SDK-style projects, rather than Python codebases.
- EclEmma is a free Eclipse plug-in for Java code coverage.
- gcov is a free alternative for code compiled with GCC; it requires coverage instrumentation to generate data.
- gofmt is a free executable included in Go installations and used from the command line.
- LLVM llvm-cov is a free open-source LLVM tool with no paid plans or usage limits stated.
Verdict
Choose Coverage.py if you need a free, flexible way to measure Python test coverage, especially when branch reports, test-specific contexts, or plugins matter. Its strongest case is the combination of broad reporting and integration with existing test commands; look elsewhere if you need coverage for another language, and avoid sysmon when your workflow depends on contexts or 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.
Questions
How much does Coverage.py cost?
Coverage.py is free, with a listed price of $0.
What platforms does it support?
The listed platforms are Linux, macOS, Windows, API, and self-hosted.
What reports can it produce?
It can produce text, HTML, XML, LCOV, and JSON reports.
Is Coverage.py open source?
Yes. It is licensed under the Apache 2.0 License.
Facts from Coverage.py's own pages
- Branch coverage
- The tool can measure whether alternative branch paths were executed. · coverage.readthedocs.io, 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, 15 Oct 2026
- Configuration
- Settings can live in .coveragerc, TOML, setup.cfg, tox.ini, or pyproject.toml files. · coverage.readthedocs.io, 15 Oct 2026
- Contexts
- Dynamic contexts can record which test function ran which lines of code. · coverage.readthedocs.io, 3 Oct 2026
- Coverage data API
- `CoverageData` provides a supported interface for reading collected coverage data. · coverage.readthedocs.io, 15 Oct 2026
- Coverage types
- It measures statement coverage by default and can also measure branch coverage. · coverage.readthedocs.io, 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, 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, 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, 3 Oct 2026
- Installation
- The documented installation command is `python3 -m pip install coverage`. · coverage.readthedocs.io, 15 Oct 2026
- Integrations
- Official examples cover pytest, unittest, and nose, and pytest commonly uses the pytest-cov plugin. · coverage.readthedocs.io, 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, 3 Oct 2026
- Licence
- The package is distributed under the Apache 2.0 licence. · pypi.org, 15 Oct 2026
- License
- Coverage.py is licensed under the Apache 2.0 License. · github.com, 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, 15 Oct 2026
- Limit: dynamic execution
- Hysen Labs cautions that dynamically generated code using exec or eval may not be captured accurately. · hysenlabs.com, 15 Oct 2026
- Limit: language scope
- Independent reviews identify Python as the supported product language, limiting use for multi-language coverage programs. · hysenlabs.com, 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, 15 Oct 2026
- Limit: test-quality signal
- Pythonlib notes that execution coverage shows whether code ran but cannot determine whether tests assert correct outcomes. · pythonlib.org, 15 Oct 2026
- Limit: tracing overhead
- Hysen Labs warns that tracing every executed line can noticeably slow large test suites. · hysenlabs.com, 15 Oct 2026
- Maintainer and adoption
- Batchelder's résumé describes him as solo maintainer since 2004 and reports use by about 34,000 PyPI packages, 65 million monthly downloads, and 365,000 GitHub repositories. · nedbatchelder.com, 15 Oct 2026
- Maintainer history
- Ned Batchelder has extended and maintained the project since 2004. · nedbatchelder.com, 15 Oct 2026
- Measurement cores
- Coverage.py offers ctrace and pytrace tracing cores plus a sysmon core; sysmon is faster for simple line and branch coverage but does not yet support dynamic contexts or plugins. · coverage.readthedocs.io, 3 Oct 2026
- Notable organization change
- A November 2025 post announced moving the repository to the coveragepy GitHub organization and described the project as essentially a one-person effort. · nedbatchelder.com, 15 Oct 2026
Where Coverage.py stands on Freedom251
- Test Coverage Tools#3 of 27