python install_error ai_generated true

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

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-01-30First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7.x active — — —
8.x active — — —

Root Cause

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

generic

中文

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

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 90% fail

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

  2. 85% fail

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