Skip to main content

pytest-order - a pytest plugin to order test execution

PyPI version Testsuite DocBuild codecov Python version PyPI - Downloads

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:

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 before and after marker 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-dependency markers if using the order-dependencies option, more information about pytest-dependency compatibility 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.

Metadata

Release files for pytest-order 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-order 1.4.0
File Size Uploaded Provenance Actions
pytest_order-1.4.0.tar.gz 49.9 kB With provenance Details for pytest_order-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-order 1.4.0
File Interpreter ABI Platform Actions
pytest_order-1.4.0-py3-none-any.whl Python 3 none any Details for pytest_order-1.4.0-py3-none-any.whl

Total release size: 64.8 kB

Release files / pytest_order-1.4.0.tar.gz

Download URL pytest_order-1.4.0.tar.gz
Size 49.9 kB
Tags Source
SHA-256 checksum
How to use checksums
327fb6eee1ae771051da13d2a0d9306d947e87f9ab8f4d6302e5d122c7472691
BLAKE2b-256 checksum
How to use checksums
fe76c7b4a2ad3758a3c2757f532c6e931aa5e387781512a71b67b6ddc19d9ef8
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 Apr 26, 2026.

Transparency log

Release files / pytest_order-1.4.0-py3-none-any.whl

Download URL pytest_order-1.4.0-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05b1710cf16bb2123294eec5bdfaee513322ff1926c0dfa86eb8be632eb264a1
BLAKE2b-256 checksum
How to use checksums
1ed0c62c07141151f259faddff6bd591f28235c37dd0c486160d0d2a0d4e6e5a
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 Apr 26, 2026.

Transparency log

Security for pytest-order 1.4.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytest_order-1.4.0.tar.gz

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 Apr 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page