Catalog
github/pytest-coverage

github

pytest-coverage

Run pytest tests with coverage, discover lines missing coverage, and increase coverage to 100%.

global
New~270
v1.0Saved Jun 26, 2026

The goal is for the tests to cover all lines of code.

Generate a coverage report with:

pytest --cov --cov-report=annotate:cov_annotate

If you are checking for coverage of a specific module, you can specify it like this:

pytest --cov=your_module_name --cov-report=annotate:cov_annotate

You can also specify specific tests to run, for example:

pytest tests/test_your_module.py --cov=your_module_name --cov-report=annotate:cov_annotate

Open the cov_annotate directory to view the annotated source code. There will be one file per source file. If a file has 100% source coverage, it means all lines are covered by tests, so you do not need to open the file.

For each file that has less than 100% test coverage, find the matching file in cov_annotate and review the file.

If a line starts with a ! (exclamation mark), it means that the line is not covered by tests. Add tests to cover the missing lines.

Keep running the tests and improving coverage until all lines are covered.

Files1
1 files · 1.0 KB

Select a file to preview

Overall Score

72/100

Grade

B

Good

Safety

85

Quality

68

Clarity

78

Completeness

62

Summary

This skill guides an agent to run pytest with coverage reporting, analyze the annotated output to identify uncovered lines, and iteratively add tests until 100% coverage is achieved. It uses pytest's built-in `--cov` and `--cov-report=annotate` flags to generate annotated source files where uncovered lines are marked with `!`.

Detected Capabilities

shell execution (pytest)file read (coverage annotations)directory navigation

Trigger Keywords

Phrases that MCP clients use to match this skill to user intent.

increase test coveragereach 100% coveragefind uncovered linescoverage analysisimprove test coverage

Use Cases

  • Achieve 100% test coverage for a Python module
  • Identify and test edge cases missed by existing test suite
  • Review annotated code to understand which lines lack test coverage
  • Iteratively improve test coverage for a specific module or test file
  • Generate and analyze coverage reports in a Python project

Quality Notes

  • Clear task definition — the goal of 100% coverage is stated upfront
  • Practical command examples with common variations (all modules, specific module, specific test file)
  • Well-structured workflow: generate report → inspect annotations → add tests → iterate
  • Explains the annotation format (! = uncovered line) to help the agent understand the output
  • Limited scope — operates only within a Python project's test and source directories
  • No error handling guidance for test failures, import errors, or missing cov_annotate directory
  • No documentation of edge cases (empty test suite, modules with no tests, coverage thresholds)
  • Does not explain how to interpret coverage metrics beyond line coverage
  • Could benefit from guidance on branch coverage vs. line coverage and pytest-cov configuration options
Model: claude-haiku-4-5-20251001Analyzed: Jun 26, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Add github/pytest-coverage to your library

Command Palette

Search for a command to run...