Skip to main content

pytest-order - a pytest plugin to order test execution

PyPI version Testsuite DocBuild codecov Python version

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 be run relative to the other tests.

pytest-order is a fork of pytest-ordering that provides some additional features - see below for details.

pytest-order works with Python 2.7 and 3.5 - 3.9, with pytest versions >= 3.7.0, and runs on Linux, MacOs and Windows.

Documentation

Apart from this overview, the following information is available:

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 darwin -- Python 3.7.1, pytest-5.4.3, py-1.8.1, pluggy-0.13.1 -- 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 ===========================

Features

pytest-order provides the following features:

  • ordering of tests by index, as shown above
  • 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 group-order-scope option
  • ordering tests with pytest-dependency markers if using the order-dependencies option
  • sparse ordering of tests via the sparse-ordering option

A usage guide for each feature can be found in the documentation.

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 code has been created by Frank Tobia, the author of that plugin, and contributors.

Comparison with pytest_ordering

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 are integrated into the order marker (for a rationale see also this issue).

Ordering relative to other tests and all of the configuration options are not available in the released version of pytest-ordering. However, most of these features are derived from issues and pull requests already existing in pytest-ordering.

Release files for pytest-order 0.10.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 0.10.0
File Size Uploaded Provenance Actions
pytest-order-0.10.0.tar.gz 38.8 kB Without provenance Details for pytest-order-0.10.0.tar.gz

Built distribution (wheel)

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

Total release size: 50.0 kB

Release files / pytest-order-0.10.0.tar.gz

Download URL pytest-order-0.10.0.tar.gz
Size 38.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2da32cb95e63fac6972d34f5ddb53997fc66305355425be0f55f4092d666293d
BLAKE2b-256 checksum
How to use checksums
88e291edadc88233345671e0c4eb3ef159603cb55bf57bafe2f3c31cddaec0c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Release files / pytest_order-0.10.0-py2.py3-none-any.whl

Download URL pytest_order-0.10.0-py2.py3-none-any.whl
Size 11.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
43cc1a45f6809dfd6dca423b2b2f9a5c3c4e364ef0329a63bf964d479af333a3
BLAKE2b-256 checksum
How to use checksums
75e142cb399c4ea62acc7d0c2292a24fdcaf57a1684d57d0e127820abeb7e40a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Security for pytest-order 0.10.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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