python
config_error
ai_generated
true
PytestUnknownMarkWarning: 未知的 pytest.mark.slow - 是否有处理它的插件?
PytestUnknownMarkWarning: Unknown pytest.mark.slow - is this a plugin needed to handle it?
ID: python/pytest-unknown-mark-warning
80%修复率
90%置信度
0证据数
2024-06-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 7.x | active | — | — | — |
| 8.x | active | — | — | — |
根因分析
使用了自定义标记(如 @pytest.mark.slow),但未在 pytest 配置中注册。pytest 会发出警告,并在 --strict-markers 下可能将其视为无效。
English
A custom marker like @pytest.mark.slow is used but not registered in pytest configuration. pytest warns and may treat it as a no-op depending on --strict-markers.
解决方案
-
96% 成功率
# pytest.ini [pytest] markers = slow: marks tests as slow integration: marks integration tests -
94% 成功率
[tool.pytest.ini_options] markers = [ "slow: marks tests as slow", "integration: marks integration tests", ]
无效尝试
常见但无效的做法:
-
70% 失败
Suppresses the warning but the marker still has no registered meaning; with --strict-markers the suite still fails.
-
80% 失败
Changes test selection semantics; tests intended to run now get skipped.