pytest-retry
Adds the ability to retry flaky tests in CI environments
Decision gist · record as of 2026-08-14
Yes, if you have flaky tests in CI and need a quick way to reduce false failures while you investigate root causes. The low install friction, permissive license, and absence of known vulnerabilities make it safe to add. Maintenance is dormant but recent, and the plugin's scope is narrow enough that stability is likely. Not recommended as a permanent solution—use it to buy time while fixing the underlying test or environment issues.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9+ and pytest 7.0.0+.
- Low friction install with a single runtime dependency on pytest.
- Maintenance is dormant but the package has received updates as recently as 2025-01-19, and no known vulnerabilities are recorded.
License · maintenance · safety
permissive license (permissive) — MIT License permits use, modification, and distribution with minimal restrictions, making it safe for both open-source and commercial projects.
last release 2025-01-19 (572 days) · last repo commit 2025-01-19 · 41 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 2,588,607 downloads/mo, #2,982 on PyPI
Alternatives
Verify before relying
pip install pytest-retry
# In conftest.py or test file:
import pytest
@pytest.mark.flaky(retries=2, delay=1)
def test_unreliable_service():
pass
# Or run globally:
# pytest --retries 2 --retry-delay 1- Whether the plugin's dormant maintenance status indicates sufficient ongoing support for production use.
- Performance impact of re-running class and module fixtures on large test suites.
- Compatibility with pytest plugins beyond pytest-html when using custom retry-outcome values.
What it is and what it does
pytest-retry extends pytest with the ability to automatically re-run tests that fail, addressing the problem of flaky tests that pass inconsistently due to timing issues, external service delays, or environment race conditions. It works as a pytest plugin with two main modes: global retry settings applied to all tests via command-line flags (--retries, --retry-delay) or configuration files, and per-test control via the @pytest.mark.flaky decorator for fine-grained retry policies.
The plugin integrates into pytest's reporting flow to track and display retried tests separately. It supports exception filtering (retry only on specific exceptions or exclude certain ones), configurable timing methods (overwrite vs. cumulative), and custom outcome labels for compatibility with other reporting tools. Teardown steps run after each failed attempt to ensure clean state before retries, though fixture setup itself is not retried. The package is designed as a pragmatic short-term solution while permanent fixes are implemented, not a substitute for addressing root causes of flakiness.
Use it for
- Retry all tests in a CI pipeline up to N times to reduce false negatives from transient environment issues.
- Mark specific tests known to be flaky with @pytest.mark.flaky to retry only those without affecting the full suite.
- Retry tests only when they fail with specific exceptions (e.g., network timeouts) while failing immediately on assertion errors.
- Add delays between retry attempts to allow intermittent services or resources to recover.
- Generate detailed reports of which tests were retried and why, to identify candidates for permanent fixes.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you have flaky tests in CI and need a quick way to reduce false failures while you investigate root causes.
The low install friction, permissive license, and absence of known vulnerabilities make it safe to add. Maintenance is dormant but recent, and the plugin's scope is narrow enough that stability is likely. Not recommended as a permanent solution—use it to buy time while fixing the underlying test or environment issues.
Install
pytest-retry on PyPI
Before you install
Low friction install with a single runtime dependency on pytest. Maintenance is dormant but the package has received updates as recently as 2025-01-19, and no known vulnerabilities are recorded.
Requires Python 3.9+ and pytest 7.0.0+.
License in practice
MIT License permits use, modification, and distribution with minimal restrictions, making it safe for both open-source and commercial projects.
Quickstart
pip install pytest-retry
# In conftest.py or test file:
import pytest
@pytest.mark.flaky(retries=2, delay=1)
def test_unreliable_service():
pass
# Or run globally:
# pytest --retries 2 --retry-delay 1
Verify before relying
- Whether the plugin's dormant maintenance status indicates sufficient ongoing support for production use.
- Performance impact of re-running class and module fixtures on large test suites.
- Compatibility with pytest plugins beyond pytest-html when using custom retry-outcome values.
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagepytest |
| Maintenance | Dormant 572 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,588,607 / month, #2,982 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Framework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.9 |
Evidence: pytest_retry-1.7.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “pytest retry plugin”
- pytest-retrypytest-retry is a pytest plugin that automatically retries failed…
- pytest-rerunfailuresA pytest plugin that automatically reruns failed tests to eliminate…
- flakyA pytest plugin that automatically reruns failing tests up to a…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also pytest-mergify · pytest-rerunfailures · flaky · pytest-fail-slow · robotframework-retryfailed · pytest-cache · pytest-loop · pytest-repeat · pytest-sentry · pytest-github-actions-annotate-failures