python config_error ai_generated true

pytest.PytestDeprecationWarning: The 'func' argument is deprecated, use 'function' instead

ID: python/pytest-warning-as-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2025-06-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active
3.9 active
3.10 active
3.11 active
3.12 active

Root Cause

Using a deprecated parameter in a pytest function, which is treated as an error due to the -W error::pytest.PytestDeprecationWarning filter.

generic

中文

在 pytest 函数中使用了已弃用的参数,由于 -W error::pytest.PytestDeprecationWarning 过滤器,这被视为错误。

Workarounds

  1. 95% success
    Update the code to use the new parameter: replace `func` with `function` in the call.
  2. 85% success
    Temporarily allow the warning in pytest.ini: `filterwarnings = default::pytest.PytestDeprecationWarning`

Dead Ends

Common approaches that don't work:

  1. 80% fail

    This hides important deprecation notices that should be addressed for future compatibility.

  2. 90% fail

    This is a temporary fix that prevents using newer features and security patches.