python
config_error
ai_generated
true
Coverage failure: total of 78.42 is less than fail-under=80.00
ID: python/pytest-coverage-threshold-fail
80%Fix Rate
86%Confidence
0Evidence
2025-03-19First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 5.0.x | active | — | — | — |
| 6.0.x | active | — | — | — |
Root Cause
pytest-cov's --cov-fail-under enforces a minimum coverage; the measured total is below the configured threshold, failing the run even if all tests pass.
generic中文
pytest-cov 的 --cov-fail-under 强制最低覆盖率;测得的总覆盖率低于配置阈值,即使所有测试通过也会失败。
Workarounds
-
90% success
# pyproject.toml [tool.coverage.run] source = ["myapp"] omit = ["myapp/migrations/*", "*/tests/*"] [tool.coverage.report] fail_under = 80 show_missing = true
-
92% success
pytest --cov=myapp --cov-report=term-missing --cov-fail-under=80 # Focus on 'Missing' column to add tests
Dead Ends
Common approaches that don't work:
-
80% fail
Hides untested code and defeats the purpose of the gate; reviewers reject blanket pragma usage.
-
85% fail
Removes the gate entirely; regressions slip through and the metric becomes meaningless.