--- id: pytest-repeat version: "0.9.4" 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) license_treatment: copyleft maintenance: aging --- # pytest-repeat — pytest plugin for repeating tests License: copyleft · Maintenance: aging · Downloads: 15.5M/mo ## 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 above — 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 pip install pytest-repeat uv add pytest-repeat 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_current - Install friction: low - Maintenance: aging - Downloads: 15.5M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags pytest repeat tests, run test multiple times, intermittent failure detection, flaky test diagnosis, pytest test repetition, stress test with pytest, repeat decorator pytest, test-reliability, pytest-plugin, flaky-test-detection [View on SkillFed](https://skillfed.io/packages/pytest-repeat) · [View on PyPI](https://pypi.org/project/pytest-repeat/)