Skip to content
Latchkey

pytest "Unknown pytest.mark" Warning Failing CI as an Error

You used a custom marker pytest doesn’t know about. With --strict-markers or a warnings-as-errors filter, that warning becomes a hard failure in CI even though it passes locally.

What this error means

CI fails with X not found in markers configuration option or a PytestUnknownMarkWarning escalated to an error. The same tests pass locally where strict mode is off.

pytest output
tests/test_slow.py:8: PytestUnknownMarkWarning: Unknown pytest.mark.slow -
is this a typo? You can register custom marks ...

# with --strict-markers:
'slow' not found in 'markers' configuration option

Common causes

Custom marker not registered

Markers like @pytest.mark.slow must be declared in config. Unregistered, they warn - and under strict mode, fail.

Strict markers or warnings-as-errors in CI

--strict-markers or filterwarnings = error (common in CI configs) turns the otherwise-harmless warning into a failing run.

How to fix it

Register your markers

Declare every custom marker so pytest recognizes it.

pyproject.toml
[tool.pytest.ini_options]
markers = [
  "slow: marks tests as slow",
  "integration: requires external services",
]

Fix typos or scope the warning filter

  1. Check the marker name isn’t a typo (@pytest.mark.slwo).
  2. Keep --strict-markers on - it catches typos - and just register valid markers.
  3. If a third-party marker triggers it, add a targeted filterwarnings ignore rather than disabling strict mode globally.

How to prevent it

  • Register all custom markers in markers config.
  • Keep --strict-markers enabled to catch typos early.
  • Scope warning filters narrowly instead of turning strict mode off.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →