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

其他格式: JSON · Markdown 中文 · English
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.

generic

解决方案

  1. 98% 成功率
    Run: pytest --cov=myapp tests/
    Or in pytest.ini:
    [pytest]
    addopts = --cov=myapp
  2. 90% 成功率
    Check that test files import the modules under test. Coverage only measures executed code.

无效尝试

常见但无效的做法:

  1. 70% 失败

    Without a path, coverage may not know which files to measure.

  2. 90% 失败

    This disables coverage reporting entirely.