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- pytest installed
- pytest-cov plugin installed
- Python project with existing tests
How to use pytest-coverage
- 1.Run pytest with coverage: pytest --cov --cov-report=annotate:cov_annotate (or specify a module with --cov=module_name)
- 2.Open the generated cov_annotate directory to view annotated source files
- 3.Review files with less than 100% coverage; skip files showing 100%
- 4.Look for lines starting with ! (exclamation mark) indicating uncovered code
- 5.Write additional tests to cover the marked lines
- 6.Re-run the coverage command to verify improvement
- 7.Repeat until all files show 100% coverage
Use cases
- 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
- 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
Use pytest --cov=your_module_name --cov-report=annotate:cov_annotate to generate coverage only for that module.
Specify the test file path: pytest tests/test_your_module.py --cov=your_module_name --cov-report=annotate:cov_annotate
A line starting with ! is not covered by any test. You need to add tests that execute that line.
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.
Related skills
More from github/awesome-copilot and the wider catalog.
git-commit
Execute semantic git commits with conventional message analysis and intelligent staging.
excalidraw-diagram-generator
Generate Excalidraw diagrams from natural language descriptions.
documentation-writer
Create structured technical documentation using the Diátaxis framework for tutorials, how-to guides, references, and explanations.
gh-cli
GitHub CLI comprehensive reference for repositories, issues, PRs, Actions, projects, releases, and all GitHub operations from the command line.
prd
Generate comprehensive Product Requirements Documents with executive summaries, user stories, technical specs, and risk analysis.
refactor
Surgical code refactoring to improve maintainability without changing behavior.