python install_error ai_generated true

ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...] pytest: error: 无法识别的参数: --cov=app --cov-report=term-missing

ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...] pytest: error: unrecognized arguments: --cov=app --cov-report=term-missing

ID: python/pytest-cov-not-found

其他格式: JSON · Markdown 中文 · English
80%修复率
90%置信度
0证据数
2024-01-30首次发现

版本兼容性

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

根因分析

未安装 pytest-cov,因此 --cov 参数不被识别。常见于 CI 环境未安装开发依赖。

English

pytest-cov is not installed, so the --cov flags are unknown. Often happens in CI where the dev requirements were not installed.

generic

解决方案

  1. 97% 成功率
    pip install pytest-cov
    # or
    pip install -e '.[test]'
    
    pytest --cov=app --cov-report=term-missing
  2. 90% 成功率
    pip install coverage
    coverage run -m pytest
    coverage report -m

无效尝试

常见但无效的做法:

  1. 90% 失败

    Still errors because the plugin is missing; the config is loaded before flag parsing.

  2. 85% 失败

    The flag itself is provided by pytest-cov; without the plugin it is also unrecognized.