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

其他格式: JSON · Markdown 中文 · English
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.

generic

解决方案

  1. 96% 成功率
    # pytest.ini
    [pytest]
    markers =
        slow: marks tests as slow
        integration: marks integration tests
  2. 94% 成功率
    [tool.pytest.ini_options]
    markers = [
      "slow: marks tests as slow",
      "integration: marks integration tests",
    ]

无效尝试

常见但无效的做法:

  1. 70% 失败

    Suppresses the warning but the marker still has no registered meaning; with --strict-markers the suite still fails.

  2. 80% 失败

    Changes test selection semantics; tests intended to run now get skipped.