API Reference

Coverage.py

A tool for measuring code coverage of Python programs, with branch analysis and HTML reports.

Official Documentation ↗
CompatibilityThis documentation covers version v7.4. Check the official docs for the latest API surface.

Installation

pippip install coverage

Methods

Coverage.py traces execution, records which lines and branches ran, and renders reports.

Key Features

  • Line and branch coverage
  • Multiple report formats
  • Combines data from parallel runs

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

Errors

The official API reference declares the following error types:

API reference evidence

Fetched from official sources on 2026-11-08T17:26:00+08:00 via WebFetch https://coverage.readthedocs.io/en/latest/api_coverage.html;WebFetch https://coverage.readthedocs.io/en/latest/cmd.html;WebFetch https://coverage.readthedocs.io/en/latest/api_exceptions.html.

FAQ

How do I enable branch coverage?
Run with --branch or set branch = true in the config so partial branch execution is counted as missing.
Why is my subprocess not covered?
Coverage does not trace child processes by default; set concurrency or use coverage run on the child as well.
How do I fail CI below a threshold?
Use --fail-under with coverage report so the command exits non-zero when coverage is below the limit.