python config_error ai_generated true

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

ID: python/pytest-skip-marker-string

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7.x active
8.x active

Root Cause

The test uses a custom mark that is not registered in pytest.ini/pyproject.toml. Pytest still applies the mark but emits a warning, and with strict-markers enabled it becomes an error.

generic

中文

测试使用了未在 pytest.ini/pyproject.toml 中注册的自定义标记。Pytest 仍会应用该标记但发出警告,启用 strict-markers 后会变成错误。

Workarounds

  1. 98% success
    # pyproject.toml
    [tool.pytest.ini_options]
    markers = [
      "slow: marks tests as slow (deselect with '-m \"not slow\"')",
      "integration: requires external services",
    ]
  2. 95% success
    # pyproject.toml
    [tool.pytest.ini_options]
    addopts = "--strict-markers"
    markers = ["slow: slow tests"]

Dead Ends

Common approaches that don't work:

  1. 85% fail

    Silences the warning but the mark remains unregistered; --strict-markers still errors and typo'd marks silently pass.

  2. 75% fail

    Loses the ability to select/exclude the test via -m; CI's 'pytest -m "not slow"' no longer filters it.