PluginBench
Skill
Official
Review
Audit score 70

pytest-coverage

github/awesome-copilot

Run pytest with coverage analysis and incrementally increase test coverage to 100%.

What is pytest-coverage?

This skill runs pytest with coverage reporting to identify untested code lines. It generates annotated source files showing which lines lack test coverage, helping you systematically add tests until achieving 100% coverage.

  • Generate coverage reports with pytest and annotated source output
  • Identify uncovered lines marked with ! in annotated files
  • Focus coverage analysis on specific modules or test files
  • Review annotated source code to find gaps in test coverage
  • Track progress toward 100% code coverage

How to install pytest-coverage

npx skills add https://github.com/github/awesome-copilot --skill pytest-coverage
Prerequisites
  • pytest installed
  • pytest-cov plugin installed
  • Python project with existing tests
Claude Code
Cursor
Windsurf
Cline

How to use pytest-coverage

  1. 1.Run pytest with coverage: pytest --cov --cov-report=annotate:cov_annotate (or specify a module with --cov=module_name)
  2. 2.Open the generated cov_annotate directory to view annotated source files
  3. 3.Review files with less than 100% coverage; skip files showing 100%
  4. 4.Look for lines starting with ! (exclamation mark) indicating uncovered code
  5. 5.Write additional tests to cover the marked lines
  6. 6.Re-run the coverage command to verify improvement
  7. 7.Repeat until all files show 100% coverage

Use cases

Good for
  • Improve test coverage for a Python module from 80% to 100%
  • Identify which lines in a critical function are not being tested
  • Generate a coverage report before merging a pull request
  • Discover edge cases and error paths that lack test coverage
  • Ensure all production code is exercised by the test suite
Who it's for
  • Python developers writing unit tests
  • QA engineers verifying test completeness
  • Teams with coverage requirements or standards
  • Developers refactoring code and needing coverage validation

pytest-coverage FAQ

How do I check coverage for a specific module?

Use pytest --cov=your_module_name --cov-report=annotate:cov_annotate to generate coverage only for that module.

How do I run coverage for specific test files?

Specify the test file path: pytest tests/test_your_module.py --cov=your_module_name --cov-report=annotate:cov_annotate

What does a ! (exclamation mark) mean in the annotated files?

A line starting with ! is not covered by any test. You need to add tests that execute that line.

Do I need to review files with 100% coverage?

No. Files showing 100% coverage mean all lines are already tested, so you can skip them and focus on files with gaps.

Full instructions (SKILL.md)

Source of truth, from github/awesome-copilot.


name: pytest-coverage description: 'Run pytest tests with coverage, discover lines missing coverage, and increase coverage to 100%.'

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.