python config_error ai_generated true

PytestUnknownMarkWarning: 未知的 pytest.mark.slow - 是拼写错误吗?你可以使用 markers 选项注册它

PytestUnknownMarkWarning: Unknown pytest.mark.slow - is this a typo? You can register it with markers option

ID: python/pytest-marker-unknown

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

版本兼容性

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

根因分析

测试中使用了自定义标记,但未在 pytest 配置中注册,导致收集期间出现警告。

English

A custom marker is used in tests but not registered in pytest configuration, causing a warning during collection.

generic

解决方案

  1. 95% 成功率
    Register the marker in pytest.ini: `[pytest]
    markers =
        slow: marks tests as slow`
  2. 90% 成功率
    Use `pytest --markers` to list all registered markers and ensure the custom one is defined.

无效尝试

常见但无效的做法:

  1. 80% 失败

    This removes useful metadata for test selection and organization.

  2. 60% 失败

    The warning may escalate to an error in future pytest versions, and it hides potential typos.