Registry / testing / pytest-order

pytest-order

JSON →
library1.5.0pypypi✓ verified 26d ago

pytest-order is a pytest plugin that allows running tests in a specific, user-defined order. It integrates with pytest using markers, providing various levels of control including custom order, dependency-based ordering, and relative ordering. The current version is 1.3.0, and it maintains an active release cadence with regular updates.

pip install pytest-order
INSTALL
IMPORT
SIG · PYTEST-ORDER
P
pytest-order
testingpythonv1.5.0
Install
2.6s avg
Import
Disk
30MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 31.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.6s · import 0.000s · 32MB
30MB installed
● package 30MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pytest.mark.order
import pytest_order
import pytest

Demonstrates basic test ordering using `@pytest.mark.order` and dependency-based ordering using `@pytest.mark.run(after='...')` and `@pytest.mark.run(before='...')`.

import pytest @pytest.mark.order(1) def test_first(): assert True @pytest.mark.order(2) def test_second(): assert True @pytest.mark.run(after='test_first') def test_dependency_on_first(): assert True @pytest.mark.run(before='test_second') def test_dependency_before_second(): assert True # To run these tests: # 1. Save the code as a Python file (e.g., test_ordering.py) # 2. Run from your terminal: pytest test_ordering.py
Debug
Known issues
breakingPython 2.7 support was dropped in version 1.0.0. Users requiring Python 2.7 compatibility must stick to pytest-order v0.11.0 or older.
fix
Upgrade to Python 3.7+ or pin pytest-order to a version <=0.11.0.
affects: >=1.0.0
gotchaUsing pytest-order with `pytest-xdist` can lead to unpredictable test execution order, as `pytest-xdist` parallelizes tests across processes, potentially breaking assumed sequential order.
fix
Avoid using `pytest-xdist` for tests where explicit ordering is critical, or use `pytest --dist=no` to disable parallelization for specific runs. Ensure dependencies are only within tests executed in the same process.
affects: All
gotchaBy default, `@pytest.mark.order` applies within its declared scope (module, class). Cross-module or cross-class ordering often requires explicit `@pytest.mark.run(after='...')` markers or the `--hierarchical-ordering` option.
fix
Use dependency markers (`@pytest.mark.run`) for cross-scope ordering, or enable `--hierarchical-ordering` and carefully define order across directories/modules.
affects: All
gotchaVersion 1.3.0 introduced the `--error-on-failed-ordering` option. Previously, tests whose order could not be resolved would simply run without an enforced order. With this flag, such tests will now fail, changing default behavior if the flag is enabled.
fix
Be aware of this option's behavior. If you prefer tests to run unordered rather than fail, ensure `--error-on-failed-ordering` is not enabled, or adjust your ordering markers to resolve all dependencies.
affects: >=1.3.0
Upgrade
Version history
1.5.0latest on PyPI · released Jun 13, 2026
Audit
Dependencies
pytestrequiredThis is a pytest plugin and requires pytest to function.
Agent activity
17 hits · last 30 days
node
12
Amazon
1
Resources
pytest-order — pip install pytest-order · libregistry