python config_error ai_generated true

PytestConfigWarning: Unknown config option: filterwarnings

ID: python/pytest-warning-filter-error

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7.4.0 active

Root Cause

pytest.ini 或 pyproject.toml 中配置了错误的 filterwarnings 语法

generic

中文

pytest.ini 或 pyproject.toml 中配置了错误的 filterwarnings 语法

Workarounds

  1. 90% success
    在 pytest.ini 中使用 filterwarnings = error::DeprecationWarning
  2. 85% success
    pytest -W error::DeprecationWarning

Dead Ends

Common approaches that don't work:

  1. 30% fail

    警告可能掩盖实际问题

  2. 40% fail

    无法控制警告,测试输出混乱