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
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.
解决方案
-
95% 成功率
Update the code to use the new parameter: replace `func` with `function` in the call.
-
85% 成功率
Temporarily allow the warning in pytest.ini: `filterwarnings = default::pytest.PytestDeprecationWarning`
无效尝试
常见但无效的做法:
-
80% 失败
This hides important deprecation notices that should be addressed for future compatibility.
-
90% 失败
This is a temporary fix that prevents using newer features and security patches.