Skip to content

--strict-markers / --strict-config via addopts silently stopped working (pytest 9 regression) #14442

@The-Compiler

Description

@The-Compiler

It seems like the OverrideIniAction compatibility code added in pytest 9 does not play nicely with addopts, and strictness options configured that way now get silently ignored since efa9eff.

pytest.ini:

[pytest]
addopts = --strict-markers --strict-config
does_not_exist = True

test_x.py:

import pytest

@pytest.mark.doesnotexist
def test_x():
    pass

with 8.4.2:

==================================== ERRORS ====================================
__________________________ ERROR collecting test_x.py __________________________
'doesnotexist' not found in `markers` configuration option
=========================== short test summary info ============================
ERROR test_x.py - Failed: 'doesnotexist' not found in `markers` configuration option
=============================== 1 error in 0.07s ===============================
ERROR: Unknown config option: does_not_exist

with 9.0.x:

=============================== warnings summary ===============================
[...]/src/_pytest/config/__init__.py:1420
  [...]/src/_pytest/config/__init__.py:1420: PytestConfigWarning: Unknown config option: does_not_exist
  
    self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")

test_x.py:3
  [...]/markertest/test_x.py:3: PytestUnknownMarkWarning: Unknown pytest.mark.doesnotexist - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    @pytest.mark.doesnotexist

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================== 1 passed, 2 warnings in 0.07s =========================

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: configrelated to config handling, argument parsing and config filetype: backward compatibilitymight present some backward compatibility issues which should be carefully noted in the changelogtype: bugproblem that needs to be addressedtype: regressionindicates a problem that was introduced in a release which was working previously

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions