pytest-order
pytest plugin to run tests in a specific order
What it is and what it does
pytest-order is a pytest plugin that gives you fine-grained control over test execution order. Instead of relying on pytest's default discovery order, you can use the `order` marker to run tests by index (e.g., `@pytest.mark.order(1)` for first), from the end using negative indices, or relative to other tests using `before` and `after` attributes. It also supports session-, module-, class-, and directory-scope ordering, and can integrate with pytest-dependency markers if configured.
The plugin is a maintained fork of the older pytest-ordering project, with additional features like relative ordering and configuration options. It works across Linux, macOS, and Windows, and supports Python versions from 3.9 through 3.14. Installation is straightforward via pip, and the only runtime dependency is pytest itself.
Use it for:
- Run setup or fixture tests first and teardown tests last to ensure proper test isolation.
- Enforce a specific sequence when tests have implicit dependencies or shared state.
- Group and order related tests using scope options for organized test execution.
- Run critical or fast tests early to fail fast, and slow or optional tests later.
- Integrate test ordering with pytest-dependency markers for declarative test relationships.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that lets you control the order in which tests run using markers, either by index number or by specifying relationships between tests.
Yes. This is an actively maintained, permissively licensed plugin with low install friction and no known vulnerabilities. It solves a real problem—test ordering—that many projects need. Use it when you have tests with implicit dependencies or when you want deterministic execution order; skip it if your tests are properly isolated and order-independent.
Install
pytest-order on PyPI
pip
pip install pytest-orderuv
uv add pytest-orderpoetry
poetry add pytest-orderInstalling pytest-order
Before you install
Low friction: pure Python wheel with only pytest as a runtime dependency. Active maintenance with a release 62 days ago and recent commits; the project is not archived and has 210 stars.
License in practice
MIT license (permissive) means you can use this plugin freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install pytest-order
import pytest
@pytest.mark.order(1)
def test_first():
assert True
@pytest.mark.order(2)
def test_second():
assert True
Requires pytest >= 6.2.4 for Python < 3.14, or pytest >= 7.4 for Python 3.14; Python >= 3.9 required.
Verify before relying
- Whether ordering handles tests with implicit dependencies or shared state correctly.
- Performance impact when ordering large test suites.
- Compatibility edge cases with other pytest plugins beyond pytest-dependency.
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 — 62 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,082,883/month — #1,973 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_order-1.5.0-py3-none-any.whl
Keywords: testing, pytest, ordering
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytest-find-dependenciesA pytest plugin that identifies dependencies…
permissive · top 5,000 on PyPI
pytest-orderingA pytest plugin that lets you control the…
permissive · top 5,000 on PyPI
pytest-integrationA pytest plugin that organizes tests into unit,…
permissive · top 15,000 on PyPI
pytest-randomlyA pytest plugin that randomly shuffles test…
permissive · top 5,000 on PyPI
pytest-dependencyA pytest plugin that marks tests as dependent…
permissive · top 5,000 on PyPI
pytest-reverseA pytest plugin that runs tests in reverse…
permissive · top 15,000 on PyPI
pytest-fail-slowA pytest plugin that marks tests as failed if…
permissive · top 15,000 on PyPI
pytest-replayA pytest plugin that records test execution…
permissive · top 15,000 on PyPI
pytest-isortA pytest plugin that automatically checks…
permissive · top 15,000 on PyPI
pytest-custom-exit-codeA pytest plugin that lets you customize the…
permissive · top 5,000 on PyPI