Skip to content

Non-finite rerun delay settings abort pytest with INTERNALERROR #390

Open

Description

@Arham-Begani

Reproduction

On master 01fd226, Windows / CPython 3.13.15 / pytest 9.1.1:

# test_recovery.py
def test_recovery(request):
    assert request.node.execution_count == 3
python -m pytest -q --reruns 2 --reruns-delay=nan test_recovery.py
python -m pytest -q --reruns 2 --reruns-delay=inf test_recovery.py
python -m pytest -q --reruns 2 --reruns-delay-backoff-factor=nan test_recovery.py
python -m pytest -q --reruns 2 --reruns-delay-backoff-factor=inf test_recovery.py

All four commands exit with code 3 / INTERNALERROR in time.sleep. NaN produces ValueError; positive-infinite delay produces OverflowError; an infinite backoff factor with the default zero delay produces NaN on the second rerun. These runs use real sleep calls. The same non-finite values can also come from ini settings and flaky marker arguments.

Expected behavior / proposed fix

Validate that the configured delay and backoff factor are finite before using them, warn, and fall back to 0 / 1.0 respectively. This follows the existing handling of negative values. Negative values (including negative infinity) would keep their current warning and defaults. Valid finite settings would retain their current behavior.

I have a focused patch in progress with regression coverage for CLI, ini, keyword markers and positional markers.

This concerns explicit NaN/infinite configuration, which is separate from #388 / #389's overflow during exponentiation of a large finite factor. The proposed patch does not change the retry formula or duplicate that implementation.

AI assistance disclosure: an AI coding assistant performed this investigation and drafted this report with the account owner's authorization.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions