Skip to content

Disable reruns with a warning instead of erroring under --pdb - #374

Merged
icemac merged 3 commits into
pytest-dev:masterfrom
LouisDeconinck:issue-248-pdb-disable-reruns
Sep 22, 2026
Merged

icemac merged 3 commits into
pytest-dev:masterfrom
LouisDeconinck:issue-248-pdb-disable-reruns

Conversation

@LouisDeconinck

@LouisDeconinck LouisDeconinck commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • --pdb combined with --reruns, --force-reruns or the flaky marker now emits a PytestWarning ("--reruns incompatible with --pdb: reruns are disabled") instead of raising UsageError
  • Global/ini reruns warn once at config time via issue_config_time_warning; marker-requested reruns warn once via item.warn
  • get_reruns_count returns 0 under --pdb, so each test runs exactly once

Closes #248

Test plan

  • Updated the four --pdb tests to assert warning + single execution (using a stub --pdbcls so no interactive session starts)
  • Existing tests pass

LouisDeconinck and others added 2 commits September 17, 2026 21:28
Combining --pdb with --reruns/--force-reruns/a flaky marker previously
raised a UsageError. Someone reaching for the debugger almost never wants
reruns, so warn and run each test once instead.

Closes pytest-dev#248.

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@icemac

icemac commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

@LouisDeconinck Thank you for working on so many open issues. Just to inform you: I have a limited review capacity of up to one PR per day. I will review all of them but probably slower than probably expected.

— written by myself, no AI used

Comment thread src/pytest_rerunfailures.py Outdated
Comment thread src/pytest_rerunfailures.py Outdated
Comment thread changes/248.feature.rst
@icemac
icemac self-requested a review September 18, 2026 07:01
Escalated PytestWarning instances (from -W error or
filterwarnings = error) are caught and re-emitted under an
"always" filter so the run continues with reruns disabled
instead of aborting with an INTERNALERROR, and the warning is
still recorded for the warnings summary. Also bump the
issue_config_time_warning stacklevel to 3 so the warning points
at check_options() rather than the helper's internals.

Co-Authored-By: Louis Deconinck <louis.dck@gmail.com>

@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.

LGTM.

@icemac
icemac merged commit e2657b2 into pytest-dev:master Sep 22, 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.

[RFC] --pdb: Friendlier default (use warning and infer --reruns 0)

2 participants