pytest-coverage by github/awesome-copilot
npx skills add https://github.com/github/awesome-copilot --skill pytest-coverage目标是让测试覆盖所有代码行。
使用以下命令生成覆盖率报告:
pytest --cov --cov-report=annotate:cov_annotate
如果你要检查特定模块的覆盖率,可以像这样指定:
pytest --cov=your_module_name --cov-report=annotate:cov_annotate
你也可以指定要运行的具体测试,例如:
pytest tests/test_your_module.py --cov=your_module_name --cov-report=annotate:cov_annotate
打开 cov_annotate 目录以查看带注释的源代码。每个源文件将对应一个文件。如果一个文件的源代码覆盖率达到 100%,意味着所有代码行都被测试覆盖,因此你无需打开该文件。
对于每个测试覆盖率低于 100% 的文件,在 cov_annotate 中找到对应的文件并进行审查。
如果一行以 !(感叹号)开头,意味着该行未被测试覆盖。请添加测试以覆盖缺失的代码行。
持续运行测试并提高覆盖率,直到所有代码行都被覆盖。
每周安装量
7.5K
代码仓库
GitHub 星标数
26.7K
首次出现时间
2026年2月25日
安全审计
Gen Agent Trust HubPassSocketPassSnykPass
已安装于
codex7.4K
gemini-cli7.4K
opencode7.4K
github-copilot7.4K
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
cursor7.4K
kimi-cli7.4K
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 Installs
7.5K
Repository
GitHub Stars
26.7K
First Seen
Feb 25, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex7.4K
gemini-cli7.4K
opencode7.4K
github-copilot7.4K
cursor7.4K
kimi-cli7.4K
97,600 周安装