pytest-loop
pytest plugin for looping tests
Decision gist · record as of 2026-08-14
Yes. The plugin is actively maintained, has no known vulnerabilities, and solves a real problem—detecting intermittent failures and stress-testing. Low install friction (one dependency, pure Python), broad Python version support, and Production/Stable status make it a safe choice for projects that need to diagnose flaky tests or validate stability under repeated execution.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.7+ and pytest 7 or newer.
- Does not work with unittest.TestCase test classes.
- Low friction: pure Python wheel with only pytest as a runtime dependency.
License · maintenance · safety
copyleft license (copyleft) — Licensed under Mozilla Public License 2.0 (copyleft). You must disclose source modifications and distribute under the same license if you modify and redistribute the package; using it unmodified as a dependency carries minimal obligation.
last release 2024-10-17 (666 days) · last repo commit 2026-05-18 · 7 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 321,529 downloads/mo, #7,622 on PyPI
Alternatives
Verify before relying
pip install pytest-loop
pytest --loop=10 test_file.py
# Or with decorator:
import pytest
@pytest.mark.loop(3)
def test_example():
pass- Whether the package handles test collection and result aggregation correctly across all pytest versions in the 7+ range.
- Performance impact of looping on large test suites or when combined with other pytest plugins.
What it is and what it does
pytest-loop is a pytest plugin that lets you run the same test or test suite repeatedly—either a fixed number of times or for a specified duration (hours, minutes, seconds). It's designed to help diagnose intermittent test failures by running tests many times in succession, and to perform stress testing by running tests continuously over a time window.
The plugin integrates with pytest's command-line interface and decorator system. You can specify repetition via `--loop=N` on the command line, or mark individual tests with `@pytest.mark.loop(N)`. For time-based looping, you use `--hours`, `--minutes`, and `--seconds` options, optionally with a `--delay` between iterations. It merges functionality from pytest-repeat and pytest-stress, and works with standard pytest test functions but not with unittest.TestCase classes.
Use it for
- Run a flaky test 1000 times with `-x` to stop at first failure and capture the failure condition.
- Stress-test a test suite for 8 hours to detect resource leaks or timing-dependent bugs.
- Mark a specific test with `@pytest.mark.loop(5)` to repeat only that test without modifying the command line.
- Diagnose race conditions by looping concurrent or async tests for an extended duration.
- Verify test stability before merging by running the full suite repeatedly for a fixed time window.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The plugin is actively maintained, has no known vulnerabilities, and solves a real problem—detecting intermittent failures and stress-testing. Low install friction (one dependency, pure Python), broad Python version support, and Production/Stable status make it a safe choice for projects that need to diagnose flaky tests or validate stability under repeated execution.
Install
pytest-loop on PyPI
Before you install
Low friction: pure Python wheel with only pytest as a runtime dependency. Actively maintained with recent commits and marked Production/Stable.
Requires Python 3.7+ and pytest 7 or newer. Does not work with unittest.TestCase test classes.
License in practice
Licensed under Mozilla Public License 2.0 (copyleft). You must disclose source modifications and distribute under the same license if you modify and redistribute the package; using it unmodified as a dependency carries minimal obligation.
Quickstart
pip install pytest-loop
pytest --loop=10 test_file.py
# Or with decorator:
import pytest
@pytest.mark.loop(3)
def test_example():
pass
Verify before relying
- Whether the package handles test collection and result aggregation correctly across all pytest versions in the 7+ range.
- Performance impact of looping on large test suites or when combined with other pytest plugins.
Package facts
| License | copyleft license copyleft |
| Python support | Supports the current Python release >=3.7 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagepytest |
| Maintenance | Actively maintained 666 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 321,529 / month, #7,622 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | 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.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Quality AssuranceTopic :: Software Development :: TestingTopic :: Utilities |
Evidence: pytest_loop-1.0.13-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 loop tests duration”
- pytest-loopA pytest plugin that repeats tests a fixed number of times or for a…
- pytest-fail-slowA pytest plugin that marks tests as failed if they exceed a specified…
- pytest-timerPytest plugin that measures and reports the execution time of…
Give your agent the search over MCP, or paste the wish link into any chat.
More Utilities packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
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.
Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.
Install it if you need to display or transform source code.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
See also pytest-repeat · pytest-retry · pytest-flakefinder · looptime · python-timeout · pytest-depends · pytest-check · pytest-rerunfailures · pytest-fail-slow · flaky