skillfed

pytest-repeat

pytest plugin for repeating tests

pytest-repeat v0.9.4 15.5M downloads/30d#1,183 on PyPI194
Copyleft license This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at… (full text in the JSON record) AGING released

What it is and what it does

pytest-repeat is a pytest plugin that adds the ability to run tests multiple times in a single invocation. You control repetition either via the --count command-line flag (to repeat all collected tests) or by decorating individual tests with @pytest.mark.repeat(count). The plugin supports different repetition scopes (function, module, class, or session) to control whether tests repeat individually or in groups.

It's primarily useful for diagnosing intermittent or flaky tests by running them repeatedly until a failure occurs (often combined with pytest's -x flag to stop on first failure). The package has been stable since its early releases and supports modern Python versions (3.9+), though it does not work with unittest.TestCase classes.

Use it for:

  • Reproduce intermittent test failures by running a test hundreds or thousands of times until it fails.
  • Stress-test a test suite to detect race conditions or state-management bugs.
  • Validate test reliability before merging by repeating critical tests multiple times in CI.
  • Debug timing-sensitive code by repeating tests with different execution orders using --repeat-scope.
  • Confirm a bug fix by repeating a previously failing test to ensure it now passes consistently.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A pytest plugin that repeats test execution a specified number of times, useful for detecting intermittent failures or stress-testing flaky tests.

Yes, if you work with flaky or intermittent test failures. The plugin is stable, has low install friction, and solves a real problem in test diagnostics. The copyleft license is straightforward for most projects. Not necessary if your test suite is deterministic and reliable.

Install

pytest-repeat on PyPI

pip

pip install pytest-repeat

uv

uv add pytest-repeat

poetry

poetry add pytest-repeat

Installing pytest-repeat

Before you install

Low friction installation with a single runtime dependency on pytest. The package is in production/stable status with recent maintenance activity (last commit 2025-09-08), though releases have slowed (494 days since last release).

License in practice

Licensed under Mozilla Public License 2.0 (MPL 2.0), a copyleft license. You must disclose source code modifications and include the license text, but can use it in proprietary projects if you comply with these terms.

Quickstart

pip install pytest-repeat

# Command line: repeat all tests 10 times
pytest --count=10 test_file.py

# Or use decorator in test code:
import pytest

@pytest.mark.repeat(3)
def test_example():
    pass

Requires Python 3.9+ and pytest 5 or newer. Does not work with unittest.TestCase test classes.

Verify before relying

  • Whether the package handles test state isolation between repetitions or if test setup/teardown behavior differs across runs.
  • Performance characteristics when repeating large test suites or individual tests thousands of times.
  • Interaction with other pytest plugins, particularly those that modify test collection or execution order.

Package facts

License This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at… (full text in the JSON record) (copyleft)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 1 — pytest
Maintenance aging — 494 days since the last release
Last repo commit
First released
Downloads 15,509,841/month — #1,183 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pytest_repeat-0.9.4-py3-none-any.whl

Development Status :: 5 - Production/StableFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)Operating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Software Development :: Quality AssuranceTopic :: Software Development :: TestingTopic :: Utilities

Tags

pytest repeat testsrun test multiple timesintermittent failure detectionflaky test diagnosispytest test repetitionstress test with pytestrepeat decorator pytest
test-reliabilitypytest-pluginflaky-test-detection

More Utilities packages