Skip to content

PY-TEST0004 · pytest_configuration_strictness

Classify whether pytest rejects configuration and marker mistakes.

This is a deterministic rule for python. Read its implementation.

Read the first pytest configuration selected by pytest’s documented file precedence. Classify the project as strict when strict = true, --strict, or all four Pytest 9 controls are enabled. These are strict_config, strict_markers, strict_parametrization_ids, and strict_xfail. Classify any incomplete nonempty subset as partial and no enabled controls as permissive. Explicit individual values override global strict mode. The corresponding flags in addopts count when pytest provides one. This complements Ruff’s PT rules because it checks project policy rather than Python test syntax.

The finding names the configuration file the suite is read from, every strictness control that is off, and how many of them are on out of how many there are. The repair is a choice, since a suite is tightened one control at a time. The category is derived only from parsed configuration and never from a model opinion.

A project that intentionally accepts dynamically registered third-party markers can configure partial as acceptable. Environment-only PYTEST_ADDOPTS is not assumed because it is not a reproducible repository setting.

[tool.pytest.ini_options]
addopts = "-q"
[tool.pytest]
strict = true
  • Cites “pytest documentation”, configuration reference. Open reference
  • Cites “pytest documentation”, strict configuration options. Open reference
  • Cites “Ruff documentation”, pytest-style rules. Open reference