Skip to content

Add pytest.ini support for only_rerun - #369

Merged
icemac merged 3 commits into
pytest-dev:masterfrom
LouisDeconinck:fix/only-rerun-ini-165
Sep 15, 2026
Merged

icemac merged 3 commits into
pytest-dev:masterfrom
LouisDeconinck:fix/only-rerun-ini-165

Conversation

@LouisDeconinck

Copy link
Copy Markdown
Contributor

Fixes #165.

Add the missing pytest.ini configuration for --only-rerun while preserving command-line precedence. The setting accepts one regex per line, matching the existing repeatable CLI option.

Included a regression test, configuration documentation, and a towncrier feature entry.

Comment thread tests/test_pytest_rerunfailures.py
@LouisDeconinck

Copy link
Copy Markdown
Contributor Author

Added coverage for multiple only_rerun entries.

@icemac icemac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up! Precedence (CLI beats ini), pyproject.toml support, -o only_rerun= and --help rendering all check out. A few remarks inline, mostly about the sibling option, tests and docs.

Comment created by Claude

Comment thread src/pytest_rerunfailures.py
Comment thread src/pytest_rerunfailures.py Outdated
Comment thread src/pytest_rerunfailures.py
Comment thread src/pytest_rerunfailures.py Outdated
Comment thread tests/test_pytest_rerunfailures.py
Comment thread docs/configuration.rst Outdated
Comment thread docs/configuration.rst
Comment thread docs/configuration.rst
@LouisDeconinck

Copy link
Copy Markdown
Contributor Author

All remarks addressed in 9e9a542:

  • rerun_except is now a registered ini option (type="linelist"), mirroring only_rerun — the fallback in _get_rerun_filter_regex is now a plain getini(regex_name) for both names.
  • Hoisted ONLY_RERUN_DESC / RERUN_EXCEPT_DESC shared by the CLI flags and addini, mentioning the one-per-line ini form.
  • check_options now compiles each CLI/ini pattern and raises UsageError naming the option, so a committed [unclosed fails fast with a clear message instead of an INTERNALERROR traceback.
  • Tests: CLI-overrides-ini precedence (asserts the R-marker lands on the ValueError test), marker-overrides-ini, ini only_rerun combined with --rerun-except exercising the four-way branch, rerun_except from ini, and invalid-regex cases for both names.
  • Docs: README gained the ini forms in both filter sections plus the marker > CLI > ini order in Priority; configuration.rst documents rerun_except, the replace-not-accumulate behavior, and the marker-interaction caveat; mark.rst mentions the ini tier.

234 tests pass; ruff and sphinx-lint clean.

@icemac
icemac merged commit 64687c9 into pytest-dev:master Sep 15, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pytest.ini support for --reruns and --only-rerun options

3 participants