Run pytest tests with coverage, discover lines missing coverage, and increase coverage to 100%.
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.
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.
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`.
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.
No, if a file shows 100% coverage, all lines are already tested, so reviewing it is not necessary.
You need Python installed along with `pytest` and the coverage plugin. The skill is compatible with Python projects that use pytest for testing.
Quick Setup:
.claude/skills/Repository
github/awesome-copilot