Coverage.py
$ coverage Community Low Riskcoverage (Coverage.py) measures statement and branch coverage for Python programs and test suites. Its clean subcommands (coverage run, coverage report, coverage json, coverage xml) give agents direct machine-readable JSON summaries and strict threshold enforcement via --fail-under.
pip install coverage Local Python instrumentation and coverage reporter tightly coupled to the project virtualenv.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Clean, non-interactive subcommands and coverage json structured output, though JSON writes to a file (-o - writes to stdout) rather than defaulting to stdout.
coverage json -o -streams JSON coverage metrics to stdoutcoverage report --fail-underprovides deterministic gate exit codes
Zero credentials or network calls; writes .coverage locally and keeps reporting read-only.
coverage reportis strictly read-only over.coverage
Installs everywhere Python runs via pip or uvx across macOS, Linux, and Windows.
- Pure PyPI wheel distribution with C extension speedups
Supports branch coverage, subprocess tracking, and JSON/XML/LCOV/HTML outputs from one .coverage file.
- Supports
json,xml,lcov, andhtmlexporters
Maintained by Ned Batchelder (nedbat/coveragepy) for 20+ years under Apache-2.0.
- Canonical Python coverage engine used by
pytest-cov
Thorough documentation on Read the Docs and clean subcommand --help.
- Detailed CLI reference at coverage.readthedocs.io
Security, Auth & Guardrails
No credentials required; records local .coverage SQLite data files inside the workspace.
Apache-2.0 open-source Python tool; free.
# Coverage.py Agent Rules - Run `coverage run -m pytest` inside the project virtualenv, then export `coverage json -o coverage.json` for structured parsing. - Use `coverage report --fail-under=80` in verification gates. - Avoid `coverage erase` unless resetting stale `.coverage` files intentionally.
Agent-Ready Command Recipes
Safe Read-Only Queries
coverage report -m
Reads an existing .coverage database and prints per-file coverage percentages and missing line ranges.
Controlled Writes & Previews
coverage run -m pytest && coverage json -o coverage.json
Instruments Python execution into .coverage and exports structured per-file coverage metrics to coverage.json.
Strengths for Agents
- +
coverage json -o -streams structured file- and line-level coverage directly to stdout. - + Single
.coverageartifact feeds text, JSON, XML, LCOV, and HTML reporters. - +
--fail-underenforces coverage thresholds with clean exit codes.
Caveats & Pitfalls
- !
coverage runmutates/overwrites.coveragein the working directory unless--data-fileis customized. - ! Needs to be invoked inside the same Python environment as the test dependencies.