Skip to content

Negative rerun counts can skip tests with exit code 0 #359

Description

@janmrow

It looks like a negative rerun count can cause a collected test not to run, while pytest exits successfully.

For example, running pytest --reruns=-1 with:

def test_should_run():
    assert False

collects one test, but does not report a test result and exits with code 0.

The same happens with negative values from:

  • reruns = -1
  • @pytest.mark.flaky(reruns=-1)
  • --force-reruns=-1

--reruns=0 works as expected here.

Negative rerun counts should probably be rejected as invalid configuration instead of allowing the test session to succeed without running the test.
If this looks worth fixing, I'd be happy to work on it.

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