Skip to content

Feature request: Option to append decorator and CLI rerun counts for additive retries #321

@Borda

Description

@Borda

Motivation

The plugin currently gives strict priority to the @pytest.mark.flaky decorator over the command-line --reruns option.

However, in environments with non-deterministic failures—such as certain machines or flaky CI runners—it would be useful to allow additive retry logic: rerun count from the decorator plus count from CLI or config.

This would allow workflow-level overrides. For example:

  • Standard deterministic tests rerun only as specified in their decorators.
  • On machines prone to network/connection failures, rerun count could be boosted via CLI for all tests, instead of replacing the decorator count.

Requested Feature

Introduce an option (e.g., --reruns-additive or --reruns-mode=append) that allows the rerun count from decorator and CLI/config to be summed.

Example

A test decorated with @pytest.mark.flaky(reruns=2) run with --reruns 4 would rerun up to 6 times if this mode is enabled.

This would ensure tests with explicit retry logic are not undermined but can be safely boosted on problematic machines without the need to rewrite test code.

Benefits

  • Greater flexibility for local and CI workflows.
  • Supports cases of nondeterminism and local network issues.
  • Cleaner separation of test-level and workflow-level rerun logic.

Possible Implementation

  • Add a new CLI/config option, e.g., --reruns-mode=append (strict could be the default).
  • Document priority/order and update rerun calculation as per mode.

Related Issues


Thank you for considering this feature!

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