---
id: ssh-pytest-coverage
name: "pytest-coverage"
url: https://skills.yangsir.net/skill/ssh-pytest-coverage
author: github
domain: testing
tags: ["pytest", "code-coverage", "unit-testing", "python-testing", "coverage.py"]
install_count: 10400
rating: 4.50 (298 reviews)
github: https://github.com/github/awesome-copilot
---

# pytest-coverage

> 运行pytest测试并计算覆盖率，发现未覆盖代码行，并帮助提升覆盖率至100%。

**Stats**: 10,400 installs · 4.5/5 (298 reviews)

## Before / After 对比

### 提升Pytest测试覆盖率保障代码质量

## Readme

# pytest-coverage

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.
Weekly Installs7.2KRepository[github/awesome-copilot](https://github.com/github/awesome-copilot)GitHub Stars25.7KFirst SeenFeb 25, 2026Security Audits[Gen Agent Trust HubPass](/github/awesome-copilot/pytest-coverage/security/agent-trust-hub)[SocketPass](/github/awesome-copilot/pytest-coverage/security/socket)[SnykPass](/github/awesome-copilot/pytest-coverage/security/snyk)Installed oncodex7.2Kgemini-cli7.1Kopencode7.1Kgithub-copilot7.1Kcursor7.1Kkimi-cli7.1K

---
*Source: https://skills.yangsir.net/skill/ssh-pytest-coverage*
*Markdown mirror: https://skills.yangsir.net/api/skill/ssh-pytest-coverage/markdown*