python
config_error
ai_generated
true
PytestUnknownMarkWarning: Unknown pytest.mark.smoke - is this a typo?
ID: python/pytest-marks-unknown-warning
80%Fix Rate
88%Confidence
0Evidence
2024-02-14First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 7.x | active | — | — | — |
| 8.x | active | — | — | — |
Root Cause
A custom marker like @pytest.mark.smoke is used but not registered in pytest configuration, so pytest warns it is unknown. With strict markers enabled, this becomes an error.
generic中文
使用了自定义标记如 @pytest.mark.smoke 但未在 pytest 配置中注册,因此 pytest 警告其未知。启用严格标记时这会变成错误。
Workarounds
-
95% success
Register markers in pytest.ini: [pytest] markers = smoke: quick smoke tests slow: long-running tests -
93% success
Or in pyproject.toml: [tool.pytest.ini_options] markers = [ 'smoke: quick smoke tests', ]
Dead Ends
Common approaches that don't work:
-
85% fail
Suppressing the warning does not register the marker; `pytest -m smoke` still fails to select tests.
-
80% fail
This changes test semantics and does not provide the intended selection behavior.