python
config_error
ai_generated
true
Coverage.py 警告: 未收集到数据。(no-data-collected)
Coverage.py warning: No data was collected. (no-data-collected)
ID: python/pytest-cov-no-data-collected
80%修复率
90%置信度
0证据数
2024-04-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 4.1 | active | — | — | — |
根因分析
pytest-cov 未收集覆盖率,因为未指定源路径或测试未导入目标模块。
English
pytest-cov did not collect coverage because the source paths are not specified or the tests did not import the target modules.
解决方案
-
98% 成功率
Run: pytest --cov=myapp tests/ Or in pytest.ini: [pytest] addopts = --cov=myapp
-
90% 成功率
Check that test files import the modules under test. Coverage only measures executed code.
无效尝试
常见但无效的做法:
-
70% 失败
Without a path, coverage may not know which files to measure.
-
90% 失败
This disables coverage reporting entirely.