python config_error ai_generated true

pytest.PytestDeprecationWarning: 'func' 参数已弃用,请改用 'function'

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

ID: python/pytest-warning-as-error

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

版本兼容性

版本状态引入弃用备注
3.8 active
3.9 active
3.10 active
3.11 active
3.12 active

根因分析

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

English

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

generic

解决方案

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

无效尝试

常见但无效的做法:

  1. 80% 失败

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

  2. 90% 失败

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