Skip to content

Pytest marker expression inspection

On pytest 9.2 and newer, BetterPy reports unregistered marker names in the -m expression supplied through addopts when strict marker mode is enabled. It reads pytest.ini, .pytest.ini, tox.ini, setup.cfg, pyproject.toml, pytest.toml and .pytest.toml.

Names declared by the winning configuration, built-in markers and markers collected from installed plugins are accepted, including string-form TOML marker declarations. Boolean operators, parentheses and marker keyword arguments are interpreted as expression syntax. Expressions that cannot be parsed statically are left to pytest rather than producing speculative warnings. Repeated -m options use the final expression before --, like pytest. strict_markers overrides the global strict setting when explicitly configured; --strict-markers enables marker strictness directly. Clustered short options such as -qm slow follow the same final-expression rule. Quoted TOML "addopts" keys are supported. Each TOML marker-array element remains one declaration, even when its description contains newlines.

The inspection stays silent for older or unknown pytest versions. The version is resolved from the configuration file's interpreter. Disable Pytest marker expression inspection in BetterPy settings to turn it off.