python config_error ai_generated true

pytest.PytestUsageError: Unknown marker 'slow' - maybe you meant 'slow_test'?

ID: python/pytest-marker-filter-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
87%Confidence
0Evidence
2026-01-18First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.10 active

Root Cause

A test uses a custom marker (e.g., @pytest.mark.slow) that is not registered in pytest.ini or conftest.py, causing pytest to raise an error when filtering or running tests with that marker.

generic

中文

测试使用了未在 pytest.ini 或 conftest.py 中注册的自定义标记(如 @pytest.mark.slow),导致 pytest 在过滤或运行带有该标记的测试时引发错误。

Workarounds

  1. 95% success
    Register the marker in pytest.ini: [pytest] markers = slow: marks tests as slow, or in conftest.py: def pytest_configure(config): config.addinivalue_line('markers', 'slow: marks tests as slow')
  2. 70% success
    Use the marker without filtering by running pytest with -k 'not slow' to skip unregistered markers, but registration is recommended.

Dead Ends

Common approaches that don't work:

  1. 50% fail

    Ignoring the marker and running all tests without filtering may work but defeats the purpose of selective test execution.

  2. 60% fail

    Using a similar built-in marker like @pytest.mark.skip may not achieve the desired filtering behavior.