python
config_error
ai_generated
true
CoverageWarning: No data was collected. (no-data-collected) warnings.warn("No data was collected.", CoverageWarning)
ID: python/pytest-cov-no-data-collected-warning
80%Fix Rate
84%Confidence
0Evidence
2024-11-19First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
coverage was started but never stopped, or the source path passed to `--cov` does not match any imported module. Common when tests import a different installed copy of the package than the one in CWD, or when `--cov=src` doesn't exist.
generic中文
coverage 已启动但从未停止,或传给 `--cov` 的源路径不匹配任何已导入模块。常见于测试导入的是已安装副本而非 CWD 中的包,或 `--cov=src` 不存在。
Workarounds
-
93% success
pip install -e . pytest --cov=myapp --cov-report=term-missing # or pytest --cov=src/myapp
-
90% success
# pyproject.toml [tool.coverage.run] source = ["myapp"] [tool.pytest.ini_options] addopts = "--cov --cov-report=term-missing"
Dead Ends
Common approaches that don't work:
-
70% fail
The report has no data to display; it just prints an empty table.
-
80% fail
Two coverage processes conflict; the .coverage file is corrupted or overwritten.