pytest-reverse
Pytest plugin to reverse test order.
What it is and what it does
pytest-reverse is a pytest plugin that reverses the order in which tests are executed. It works by adding a --reverse flag to pytest, allowing you to run your test suite backwards instead of in the default or randomized order. The plugin is automatically discovered by pytest once installed.
Test reversal helps identify tests that depend on execution order or shared state—a common source of flaky tests and false positives. By running tests in reverse, you can detect whether a passing test only passes because an earlier test set up some state, or whether a test fails only when preceded by a specific other test. This is a lightweight alternative to full randomization for uncovering test isolation issues.
Use it for:
- Run your test suite backwards to catch tests that pass only due to side effects from earlier tests.
- Debug flaky tests by checking if they fail when executed in reverse order.
- Add --reverse to pytest.ini to make reverse execution the default for your project.
- Verify test independence before committing code that modifies test fixtures or setup.
- Complement randomized testing strategies with a deterministic reverse run.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that runs tests in reverse order to detect test interdependencies and ordering issues.
Yes. Low install friction, no security issues, actively maintained, and a focused tool that solves a real problem in test reliability. Useful for any project where test ordering might mask failures or dependencies.
Install
pytest-reverse on PyPI
pip
pip install pytest-reverseuv
uv add pytest-reversepoetry
poetry add pytest-reverseInstalling pytest-reverse
Before you install
Low friction: pure Python wheel with only pytest as a runtime dependency. Actively maintained with recent releases; last commit 2026-08-13.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal obligations.
Quickstart
pip install pytest-reverse
pytest --reverse
Requires Python 3.9 or later.
Verify before relying
- Whether test reversal alone is sufficient to catch all ordering-dependent failures or if it works best combined with other techniques.
- Performance impact when reversing large test suites.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pytest |
| Maintenance | actively maintained — 339 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 74,991/month — #14,761 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_reverse-1.9.0-py3-none-any.whl
Keywords: pytest, reverse
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
pytest-randomlyA pytest plugin that randomly shuffles test…
permissive · top 5,000 on PyPI
pytest-find-dependenciesA pytest plugin that identifies dependencies…
permissive · top 5,000 on PyPI
pytest-random-orderA pytest plugin that randomizes the order in…
permissive · top 5,000 on PyPI
pytest-socketA pytest plugin that blocks or restricts socket…
permissive · top 5,000 on PyPI
pytest-orderA pytest plugin that lets you control the order…
permissive · top 5,000 on PyPI
pytest-incrementalpytest-incremental is a pytest plugin that…
permissive · top 15,000 on PyPI
pytest-dependsA pytest plugin that lets you declare…
permissive · top 15,000 on PyPI
pytest-splitA pytest plugin that divides a test suite into…
permissive · top 5,000 on PyPI
pytest-specpytest-spec is a pytest plugin that reformats…
copyleft · top 15,000 on PyPI