pytest-coverage
Run pytest tests with coverage, discover lines missing coverage, and increase coverage to 100%.
Security Assessment
About pytest-coverage
The pytest-coverage skill enables developers to run Python tests with integrated code coverage analysis, helping to identify lines of code that are not executed by existing tests. This ensures that the entire codebase is thoroughly tested and any untested paths are highlighted, ultimately aiming to achieve 100% test coverage. By pinpointing missing coverage, developers can systematically improve their test suite and maintain higher code quality, reducing the likelihood of undetected bugs in production.
FAQ
How do I generate a coverage report for my project?
You can generate a coverage report by running `pytest --cov --cov-report=annotate:cov_annotate`. This creates annotated source files in the `cov_annotate` directory showing which lines are covered and which are missing coverage.
Can I check coverage for a specific module or test file?
Yes, you can specify a module using `--cov=your_module_name` and optionally target specific test files like `pytest tests/test_your_module.py --cov=your_module_name --cov-report=annotate:cov_annotate`.
What does the exclamation mark in the annotated files mean?
A line starting with `!` in the annotated files indicates that the line is not covered by tests. You should add tests to cover these lines to increase overall coverage.
Do I need to review files with 100% coverage?
No, if a file shows 100% coverage, all lines are already tested, so reviewing it is not necessary.
Are there any prerequisites for using pytest-coverage?
You need Python installed along with `pytest` and the coverage plugin. The skill is compatible with Python projects that use pytest for testing.
Install pytest-coverage
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
github/awesome-copilot