python config_error ai_generated true

FAIL 未达到要求的80%测试覆盖率。总覆盖率:75.00%

FAIL Required test coverage of 80% not reached. Total coverage: 75.00%

ID: python/pytest-cov-fail-under

其他格式: JSON · Markdown 中文 · English
80%修复率
87%置信度
0证据数
2025-08-15首次发现

版本兼容性

版本状态引入弃用备注
3.x active — — —

根因分析

测试套件的覆盖率低于 --cov-fail-under 设置的阈值。这导致 pytest 以非零状态退出,使 CI 失败。

English

The test suite's coverage is below the threshold set by --cov-fail-under. This causes pytest to exit with a non-zero status, failing CI.

generic

解决方案

  1. 95% 成功率
    Use coverage report to identify missing lines:
    coverage report -m
    Then add tests targeting those lines.
  2. 90% 成功率
    In .coveragerc:
    [run]
    omit =
        */tests/*
        */migrations/*
  3. 80% 成功率
    Use # pragma: no branch for branches that are impossible to test.

无效尝试

常见但无效的做法:

  1. 70% 失败

    This may pass CI but reduces the quality gate, allowing coverage to drop further over time.

  2. 90% 失败

    This disables the coverage check entirely, eliminating the quality gate.

  3. 95% 失败

    This is a form of cheating and may hide genuinely untested code.