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 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 Python 3.6 - 3.10, with pytest versions >= 5.0.0 for all versions except Python 3.10, and for pytest >= 6.2.4 for Python 3.10. 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

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

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

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-1.0.1.tar.gz (42.4 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-1.0.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest-order-1.0.1.tar.gz
  • Upload date:
  • Size: 42.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pytest-order-1.0.1.tar.gz
Algorithm Hash digest
SHA256 5dd6b929fbd7eaa6d0ee07586f65c623babb0afe72b4843c5f15055d6b3b1b1f
MD5 75e7b35e9bd40d088bdcaccf33e90340
BLAKE2b-256 15a54afa19f7c88f1574a9ec75fa644dac3c3478acedc79d5242fd5573f209f2

See more details on using hashes here.

File details

Details for the file pytest_order-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pytest_order-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pytest_order-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bbe6e63a8e23741ab3e810d458d1ea7317e797b70f9550512d77d6e9e8fd1bbb
MD5 9045377c52092f0c98816d80810094f6
BLAKE2b-256 03e7fc6934462f6b68a98561032243f3d9241bb5aa61fc79469288dc4a353353

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