python config_error ai_generated true

Coverage.py warning: No data was collected. (no-data-collected)

ID: python/pytest-cov-no-data-collected

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-04-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
4.1 active

Root Cause

pytest-cov did not collect coverage because the source paths are not specified or the tests did not import the target modules.

generic

中文

pytest-cov 未收集覆盖率,因为未指定源路径或测试未导入目标模块。

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 70% fail

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

  2. 90% fail

    This disables coverage reporting entirely.