Skip to main content

pytest plugin to run your tests in a specific order

Project description

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.10, 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.

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 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 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-order-0.11.0.tar.gz (39.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_order-0.11.0-py2.py3-none-any.whl (11.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pytest-order-0.11.0.tar.gz.

File metadata

  • Download URL: pytest-order-0.11.0.tar.gz
  • Upload date:
  • Size: 39.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for pytest-order-0.11.0.tar.gz
Algorithm Hash digest
SHA256 044e4c90d86895792e6da7577df7fed6440bd59ee593374f9252679a252d8eaa
MD5 06a34d910bc5b4c66fb06e597d7bae10
BLAKE2b-256 e5111778df331dd343dd957f3e70264d4dcd4f26b01d2b087d7216df41042f3b

See more details on using hashes here.

File details

Details for the file pytest_order-0.11.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pytest_order-0.11.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for pytest_order-0.11.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ed3c06be2e6964f9f37c1e86c4ef1477cf4f2502d6b538bb334fd1c629a1cae2
MD5 11b088ebb6690775f1573e9c8c8a26ba
BLAKE2b-256 8532924fc7d88ada03572b550342a332cebd4f442d1a2cc7199d6388ccc79b33

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page