python
config_error
ai_generated
true
PytestUnknownMarkWarning: Unknown pytest.mark.slow - is this a typo? You can register custom marks to avoid this warning
ID: python/pytest-mark-unknown-warning
80%Fix Rate
90%Confidence
0Evidence
2024-02-27First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 7.x | active | — | — | — |
| 8.x | active | — | — | — |
Root Cause
A custom marker (e.g., @pytest.mark.slow) is used but not registered, so pytest emits a warning and -m 'slow' filtering may not behave as expected.
generic中文
使用了自定义标记(例如 @pytest.mark.slow)但未注册,因此 pytest 发出警告,并且 -m 'slow' 过滤可能无法按预期工作。
Workarounds
-
98% success
# pytest.ini [pytest] markers = slow: marks tests as slow integration: requires external services -
95% success
# pyproject.toml [tool.pytest.ini_options] markers = [ "slow: marks tests as slow", "integration: requires external services", ]
Dead Ends
Common approaches that don't work:
-
80% fail
Silences the warning but -m filtering still doesn't recognize the mark.
-
70% fail
-k matches names, not markers; results differ.
-
30% fail
Works but duplicates config; pytest.ini is simpler and canonical.