Skip to content

Add --rerun-warning flag to emit a warning on each scheduled rerun - #375

Open
LouisDeconinck wants to merge 6 commits into
pytest-dev:masterfrom
LouisDeconinck:issue-318-rerun-warning
Open

LouisDeconinck wants to merge 6 commits into
pytest-dev:masterfrom
LouisDeconinck:issue-318-rerun-warning

Conversation

@LouisDeconinck

@LouisDeconinck LouisDeconinck commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds an opt-in --rerun-warning flag that emits a PytestWarning each time a test is scheduled for rerun
  • Intended for CI visibility, e.g. turning warnings into annotations via pytest-github-actions-annotate-failures
  • Opt-in so filterwarnings = error users are unaffected; the caveat is documented in --help and the README

Closes #318

Test plan

  • Test asserting the warning appears in the warnings summary and the rerun still happens
  • Test asserting no warning is emitted without the flag

LouisDeconinck and others added 2 commits September 17, 2026 21:29
Emits a PytestWarning per rerun so CI tooling such as
pytest-github-actions-annotate-failures can surface flaky tests as
annotations. Opt-in so filterwarnings=error users are unaffected.

Closes pytest-dev#318.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Comment thread src/pytest_rerunfailures.py Outdated
Comment thread src/pytest_rerunfailures.py
…ning

# Conflicts:
#	tests/test_pytest_rerunfailures.py
An escalated warning is recorded through pytest's warning hook instead,
as already done for the --pdb warning.
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 ability to raise runtime warnings on reruns

2 participants