python config_error ai_generated true

PytestUnknownMarkWarning: Unknown pytest.mark.slow - is this a plugin needed to handle it?

ID: python/pytest-unknown-mark-warning

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-06-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7.x active — — —
8.x active — — —

Root Cause

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

中文

使用了自定义标记(如 @pytest.mark.slow),但未在 pytest 配置中注册。pytest 会发出警告,并在 --strict-markers 下可能将其视为无效。

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 70% fail

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

  2. 80% fail

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