coverage-py-analysis
БесплатноБез исполняемых скриптовНе проверенUse for any question or task about Python code coverage with pytest or unittest, including quick how-to questions, a CI gate on a minimum, and coverage that…
от testland★ 18 звёзд на GitHubОб этом скилле
coverage-py-analysis
Overview
Per coveragepy-docs:
"Coverage.py is a tool for measuring code coverage of Python programs. It monitors your program, noting which parts of the code have been executed, then analyzes the source to identify code that could have been executed but was not."
The tool is the de facto Python coverage solution; pytest's
pytest-cov plugin is a thin convenience wrapper around it. As of
the source fetch on 2026-05-05, "Current version is 7.13.5 (March
2026), supporting Python 3.10-3.15 alpha and PyPy3"
(coveragepy-docs).
When to use
- The project tests with pytest, unittest, or nose, and the team needs PR-time coverage signal.
- A SaaS coverage dashboard (Codecov, Coveralls, Codacy) consumes LCOV or Cobertura - both are first-party output formats.
- A multi-language project (Python + JS + Java) needs per-language coverage in a unified format (LCOV).
Step 1 - Install + replace python with coverage run
pip install coverage[toml]
[toml] is needed only for older Python (<3.11); newer ones include
TOML parsing in stdlib.
Per coveragepy-docs:
"Replace your normal python command with this tool (e.g.,
python something.pybecomescoverage run something.py)."
In practice, run pytest under coverage:
coverage run -m pytest
coverage report
Or via pytest-cov:
pytest --cov=src --cov-branch --cov-report=term-missing --cov-report=xml --cov-report=lcov
Step 2 - Enable branch coverage
Per coveragepy-docs, coverage.py defaults to statement coverage (line coverage). Branch coverage requires opt-in:
coverage run --branch -m pytest
Or in .coveragerc:
[run]
branch = True
Branch coverage catches the case where every line is executed but
not every condition arm - if x and y where only the true branch
is tested.
Step 3 - Author .coveragerc
The canonical config (.coveragerc or [tool.coverage] in
pyproject.toml):
[run]
source = src
branch = True
parallel = True
omit =
*/tests/*
*/migrations/*
*/conftest.py
[report]
fail_under = 80
show_missing = True
skip_covered = False
exclude_lines =
pragma: no cover
raise NotImplementedError
if __name__ == .__main__.:
[xml]
output = coverage.xml
[html]
directory = htmlcov
[lcov]
output = coverage.lcov
[json]
output = coverage.json
Per coveragepy-docs, the four key [run] settings:
| Setting | Use |
|---|---|
source |
Restricts coverage to specific paths (avoids inflating from third-party). |
branch |
Enables branch coverage (Step 2). |
omit |
Excludes files (tests, migrations, generated code). |
fail_under |
Fails coverage report if the total drops below the threshold. |
exclude_lines patterns let the team mark unreachable / not-meant-to-be-tested
code with magic comments (# pragma: no cover) and sentinel patterns
like raise NotImplementedError.
Step 4 - Combine parallel runs
Pytest-xdist runs tests across multiple processes; each process
writes its own .coverage.<host>.<pid>.<rand> file. Per
coveragepy-docs, coverage combine merges them:
coverage run --parallel -m pytest -n auto
coverage combine
coverage report
coverage xml
coverage lcov
--parallel (or parallel = True in .coveragerc) makes coverage
write per-process files instead of overwriting .coverage.
coverage combine then merges them into the final .coverage.
Without combine, only the last process's data survives - the most common new-user mistake.
Step 5 - Pick the output format
Per coveragepy-docs, coverage.py emits five formats:
| Command | Output | Use |
|---|---|---|
coverage report |
Terminal text | CI log readability + dev loop. |
coverage html |
htmlcov/index.html |
Human review with per-line drill-down. |
coverage xml |
coverage.xml (Cobertura format) |
Jenkins, Azure DevOps; cross-tool aggregation. |
coverage lcov |
coverage.lcov |
Codecov, Coveralls, cross-tool diffing. |
coverage json |
coverage.json |
Programmatic post-processing. |
A typical CI emits xml + lcov + report:
coverage xml # for Jenkins
coverage lcov # for Codecov
coverage report # for the CI log
Step 6 - coverage report --fail-under
For a self-contained gate (without external scripting):
coverage report --fai
Установить coverage-py-analysis в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл coverage-py-analysis?
Use for any question or task about Python code coverage with pytest or unittest, including quick how-to questions, a CI gate on a minimum, and coverage that drops when tests run in parallel with xdist: coverage run, branch coverage, combining parallel data, .coveragerc source, omit and fail_under, and terminal, HTML, Cobertura XML, LCOV or JSON reports for CI.
Как установить скилл coverage-py-analysis?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл coverage-py-analysis запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic