python config_error ai_generated true

PytestUnknownMarkWarning: 未知的 pytest.mark.slow - 是否拼写错误?您可以注册自定义标记以避免此警告。

PytestUnknownMarkWarning: Unknown pytest.mark.slow - is this a typo? You can register custom marks to avoid this warning.

ID: python/pytest-mark-unknown

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

版本兼容性

版本状态引入弃用备注
7.x active
8.x active

根因分析

使用了如 @pytest.mark.slow 的自定义标记,但未在 pytest.ini、pyproject.toml 或 conftest.py 中注册,pytest 将其视为拼写错误。

English

A custom marker such as @pytest.mark.slow is used without being registered in pytest.ini, pyproject.toml, or conftest.py, so pytest treats it as a typo.

generic

解决方案

  1. 98% 成功率
    # pytest.ini
    [pytest]
    markers =
        slow: marks tests as slow
        integration: needs external services
  2. 98% 成功率
    # pyproject.toml
    [tool.pytest.ini_options]
    markers = [
      'slow: marks tests as slow',
    ]

无效尝试

常见但无效的做法:

  1. 70% 失败

    Silences the warning but --strict-markers will still fail the run, and the marker remains unregistered.

  2. 80% 失败

    Changes test semantics; skip is not the same as a user-defined tag used for selection.