pytest-repeat
pytest plugin for repeating tests
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-repeatuv
uv add pytest-repeatpoetry
poetry add pytest-repeatInstalling 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
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytest-loopA pytest plugin that repeats tests a fixed…
copyleft · top 15,000 on PyPI
pytest-flakefinderA pytest plugin that runs tests multiple times…
permissive · top 5,000 on PyPI
pytest-rerunfailuresA pytest plugin that automatically reruns…
copyleft · top 1,000 on PyPI
pytest-plusA pytest plugin that adds optional test-count…
permissive · top 15,000 on PyPI
pytest-retrypytest-retry is a pytest plugin that…
permissive · top 5,000 on PyPI
pytest-instafailA pytest plugin that displays test failures and…
permissive · top 5,000 on PyPI
flakyA pytest plugin that automatically reruns…
permissive · top 5,000 on PyPI
pytest-sentryA pytest plugin that sends test failure and…
permissive · top 15,000 on PyPI
pytest-dependsA pytest plugin that lets you declare…
permissive · top 15,000 on PyPI
pytest-monitorA pytest plugin that automatically measures and…
permissive · top 15,000 on PyPI