Skip to the content
Know your tech before you buy it. Makers: get listed from $49/mo

Coverage.py

coverage.readthedocs.io

  • Free plan
  • Open source
  • Windows
  • macOS
  • Linux
  • API
  • Self-hosted

What Coverage.py is

Coverage.py is a free tool for measuring which parts of Python programs run and which executable code remains unvisited. Developers can use that information to assess what their test suites exercise. It measures statement coverage by default and can also measure branch coverage, then produce text, HTML, XML, LCOV, or JSON reports. Dynamic contexts can link executed lines to the test function that ran them. Coverage.py runs test suites through their usual command; a pytest-cov plugin is 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. Results are stored in a SQLite database, and advanced use can rely on the Coverage.py API. Its documented interpreter support includes Python 3.10 through 3.15 rc2 and PyPy3 versions 3.10 and 3.11. It runs on Linux, macOS, and Windows, and can be self-hosted. Coverage.py is licensed under Apache 2.0.

Who it suits

Coverage.py suits Python developers who want to see which code their tests exercise and which they miss. Dynamic contexts and the API can support more detailed analysis.

Good to know, and what to watch

  • Statement and branch coverage are available
  • Reports come in five listed formats
  • Dynamic contexts associate lines with test functions
  • Third-party plugins can measure selected non-Python files
  • Free and licensed under Apache 2.0
  • The tool measures Python coverage by default
  • The sysmon core lacks dynamic contexts and plugins

Coverage.py

Free

Free

Free

Free plan

Getting started

  1. Open the Coverage.py documentation website
  2. Choose a supported Linux, macOS, Windows, API, or self-hosted environment
  3. Run your test suite through its usual command
  4. Select statement or branch measurement
  5. Generate a text, HTML, XML, LCOV, or JSON report

Limits to check

The sysmon measurement core does not support dynamic contexts or third-party plugins. Coverage.py otherwise has a free plan for the listed Python coverage features.

The verdict

Coverage.py offers a focused way to measure Python test coverage, with multiple report formats and extensibility options. The sysmon core's limits matter when dynamic contexts or plugins are needed.

Questions people ask

What does Coverage.py measure?

It measures which parts of Python programs ran, using statement coverage by default and optional branch coverage.

Which report formats are available?

Coverage.py can produce text, HTML, XML, LCOV, and JSON reports.

Does it support self-hosting?

Yes. The listed platforms include self-hosted use, as well as Linux, macOS, and Windows.

Can coverage be linked to individual tests?

Yes. Dynamic contexts can record which test function ran particular lines.

What license does Coverage.py use?

Coverage.py is licensed under Apache 2.0.

What the maker publishes

Branch coverage
The tool can measure whether alternative branch paths were executed. source
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. source
Configuration
Settings can live in .coveragerc, TOML, setup.cfg, tox.ini, or pyproject.toml files. source
Contexts
Dynamic contexts can record which test function ran which lines of code. source
Coverage data API
`CoverageData` provides a supported interface for reading collected coverage data. source
Coverage types
It measures statement coverage by default and can also measure branch coverage. source
Database format
Collected results are stored in a SQLite database, whose schema is documented as advanced and subject to change. source
Documentation and support
Help is offered through extensive Read the Docs material, Python forums, Python Discord, GitHub issues, and optional Tidelift support. source
Extensibility
Third-party plugins can extend measurement to non-Python files, such as mapping executed Python back to Django HTML templates. source
Installation
The documented installation command is `python3 -m pip install coverage`. source
Integrations
Coverage.py can run test suites through their usual command, and pytest-cov is an available pytest plugin that the docs say is unnecessary for most purposes. source
Integrations
Official examples cover pytest, unittest, and nose, and pytest commonly uses the pytest-cov plugin. source
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. source
Licence
The package is distributed under the Apache 2.0 licence. source
License
Coverage.py is licensed under the Apache 2.0 License. source
Limit: default test distinction
ClickUp notes that Coverage.py does not automatically distinguish test code from the application code being tested. source
Limit: dynamic execution
Hysen Labs cautions that dynamically generated code using exec or eval may not be captured accurately. source
Limit: language scope
Independent reviews identify Python as the supported product language, limiting use for multi-language coverage programs. source
Limit: measured performance
A 2023 arXiv study measured median overhead of 180% on CPython and 1,300% on PyPy for coverage.py. source
Limit: test-quality signal
Pythonlib notes that execution coverage shows whether code ran but cannot determine whether tests assert correct outcomes. source
Limit: tracing overhead
Hysen Labs warns that tracing every executed line can noticeably slow large test suites. source
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. source
Maintainer history
Ned Batchelder has extended and maintained the project since 2004. source
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. source

Checked against the maker's pages on 15 Oct 2026.