pytest-order - a pytest plugin to order test execution
pytest-order is a pytest plugin that allows you to customize the order in which
your tests are run. It uses the marker order that defines when a specific
test shall run, either by using an ordinal number, or by specifying the
relationship to other tests.
pytest-order is a fork of
pytest-ordering that provides
additional features like ordering relative to other tests.
pytest-order works with all supported Python versions, with pytest versions >= 6.2.4
for Python < 3.14, and pytest >= 7.4 for Python 3.14.
pytest-order runs on Linux, macOS and Windows.
Documentation
Apart from this overview, the following information is available:
- usage documentation for the latest release
- usage documentation for the current main branch
- most examples shown in the documentation can also be found in the repository
- the Release Notes with a list of changes in the latest versions
- a list of open issues
in the original project and their handling in
pytest-order
Features
pytest-order provides the following features:
- ordering of tests by index
- ordering of tests both from the start and from the end (via negative index)
- ordering of tests relative to each other
(via the
beforeandaftermarker attributes) - session-, module- and class-scope ordering via the order-scope option
- directory scope ordering via the order-scope-level option
- hierarchical module and class-level ordering via the order-group-scope option
- ordering tests with
pytest-dependencymarkers if using the order-dependencies option, more information aboutpytest-dependencycompatibility here - sparse ordering of tests via the sparse-ordering option
- usage of custom markers for ordering using the order-marker-prefix option
Overview
(adapted from the original project)
Have you ever wanted to easily run one of your tests before any others run? Or run some tests last? Or run this one test before that other test? Or make sure that this group of tests runs after this other group of tests?
Now you can.
Install with:
pip install pytest-order
This defines the order marker that you can use in your code with
different attributes.
For example, this code:
import pytest
@pytest.mark.order(2)
def test_foo():
assert True
@pytest.mark.order(1)
def test_bar():
assert True
yields the output:
$ pytest test_foo.py -vv
============================= test session starts ==============================
platform linux -- Python 3.11.11, pytest-9.0.3, pluggy-1.6.0 -- env/bin/python
plugins: order
collected 2 items
test_foo.py:7: test_bar PASSED
test_foo.py:3: test_foo PASSED
=========================== 2 passed in 0.01 seconds ===========================
Contributing
Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.
License
Distributed under the terms of the MIT
license, pytest-order is free and open source software.
History
This is a fork of pytest-ordering.
That project is not maintained anymore, and there are several helpful PRs
that are now integrated into pytest-order. The idea and most of the
initial code has been created by Frank Tobia, the author of that plugin, and
contributors.
While derived from pytest_ordering, pytest-order is not compatible
with pytest-ordering due to the changed marker name (order instead of
run). Additional markers defined in pytest_ordering are all integrated
into the order marker (for a rationale see also
this issue).
Ordering relative to other tests and all the configuration options are not
available in the released version of pytest-ordering.
However, most of these features are derived from or inspired by
issues
and pull requests already existing in pytest-ordering.
Release files for pytest-order 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_order-1.5.0.tar.gz | 54.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_order-1.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 70.8 kB
Release files / pytest_order-1.5.0.tar.gz
| Download URL | pytest_order-1.5.0.tar.gz |
|---|---|
| Size | 54.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
96acd7587b5a2855dcaa4a898288103d202894a61afd813adbc9b77aab04d90d
|
|
BLAKE2b-256 checksum How to use checksums |
97d882a5dc2aad3392f66c9741960fcbeeb45dd4d62eedb218aed6c52eea36eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 13, 2026.
Transparency logRelease files / pytest_order-1.5.0-py3-none-any.whl
| Download URL | pytest_order-1.5.0-py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
667ba2b7303fe2c529848663e0a41dfb0cc4d64f09f87272e4a9a1751efb52b2
|
|
BLAKE2b-256 checksum How to use checksums |
fd5cbd6a85b44beb8bd74c0e86ab699ef0e096e260dc90458b84fc54c28e4335
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 13, 2026.
Transparency log