python
config_error
ai_generated
true
CoverageWarning: No contexts were measured warnings.warn("No contexts were measured")
ID: python/pytest-cov-context-not-configured
80%Fix Rate
80%Confidence
0Evidence
2024-08-27First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 5.x | active | — | — | — |
Root Cause
`--cov-context=test` was passed but the coverage config does not enable dynamic contexts, or the coverage version does not support the requested context mode.
generic中文
传入了 `--cov-context=test`,但 coverage 配置未启用动态上下文,或 coverage 版本不支持所请求的上下文模式。
Workarounds
-
90% success
Enable dynamic contexts in coverage config: # pyproject.toml [tool.coverage.run] dynamic_context = "test_function" # then run: pytest --cov=myapp --cov-context=test
-
85% success
Or set the env var before running: COVERAGE_DYNAMIC_CONTEXT=test_function pytest --cov=myapp --cov-context=test
Dead Ends
Common approaches that don't work:
-
85% fail
Only affects the failure threshold; contexts still not measured.
-
60% fail
Hides the warning but loses per-test coverage reporting that was the goal.