$npx -y skills add github/awesome-copilot --skill pytest-coverageRun pytest tests with coverage, discover lines missing coverage, and increase coverage to 100%.
| 1 | The goal is for the tests to cover all lines of code. |
| 2 | |
| 3 | Generate a coverage report with: |
| 4 | |
| 5 | pytest --cov --cov-report=annotate:cov_annotate |
| 6 | |
| 7 | If you are checking for coverage of a specific module, you can specify it like this: |
| 8 | |
| 9 | pytest --cov=your_module_name --cov-report=annotate:cov_annotate |
| 10 | |
| 11 | You can also specify specific tests to run, for example: |
| 12 | |
| 13 | pytest tests/test_your_module.py --cov=your_module_name --cov-report=annotate:cov_annotate |
| 14 | |
| 15 | Open the cov_annotate directory to view the annotated source code. |
| 16 | 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. |
| 17 | |
| 18 | For each file that has less than 100% test coverage, find the matching file in cov_annotate and review the file. |
| 19 | |
| 20 | If a line starts with a ! (exclamation mark), it means that the line is not covered by tests. |
| 21 | Add tests to cover the missing lines. |
| 22 | |
| 23 | Keep running the tests and improving coverage until all lines are covered. |