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

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

Apart from the changed marker name, there is a number of features not implemented in the released version of pytest-ordering:

  • support for ordering tests relative to each other
  • support for module and class-scope ordering via a config option
  • optional support for ordering tests with pytest-dependency markers
  • optional support for sparse ordering
  • optional invocation of the plugin before (instead of after) other plugins

Most of these features are derived from issues and pull requests in pytest-ordering. A description of each feature can be found in the documentation.

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.9.4.tar.gz (27.0 kB view hashes)

Uploaded Source

Built Distribution

pytest_order-0.9.4-py2.py3-none-any.whl (7.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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