Package: pytest-order
pytest-order- a pytest plugin to order test executionpytest-orderis a pytest plugin that allows you to customize the order in which
your tests are run. It uses the markerorderthat defines when a specific
test shall run, either by using an ordinal number, or by specifying the
relationship to other tests.pytest-orderis a fork ofpytest-orderingthat provides
additional features like ordering relative to other tests.pytest-orderworks with Python 3.7 - 3.12, with pytest
versions >= 5.0.0 for all versions up to Python 3.9, and for pytest >=
6.2.4 for Python >= 3.10.pytest-orderruns on Linux, macOS and Windows.DocumentationApart from this overview, the following information is available:usage documentation for thelatest releaseusage documentation for thecurrent main branchmost examples shown in the documentation can also be found in therepositorytheRelease Noteswith a list of changes in the latest versionsalist of open issuesin the original project and their handling inpytest-orderFeaturespytest-orderprovides the following features:ordering of testsby indexordering of tests both from the start and from the end (via negative
index)ordering of testsrelative to each other(via thebeforeandaftermarker attributes)session-, module- and class-scope ordering via theorder-scopeoptiondirectory scope ordering via theorder-scope-leveloptionhierarchical module and class-level ordering via theorder-group-scopeoptionordering tests withpytest-dependencymarkers if using theorder-dependenciesoption,
more information aboutpytest-dependencycompatibilityheresparse ordering of tests via thesparse-orderingoptionusage of custom markers for ordering using thesparse-orderingoptionOverview(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-orderThis defines theordermarker 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 Trueyields 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 ===========================ContributingContributions are very welcome. Tests can be run withtox, please ensure
the coverage at least stays the same before you submit a pull request.LicenseDistributed under the terms of theMITlicense,pytest-orderis free and open source software.HistoryThis is a fork ofpytest-ordering.
That project is not maintained anymore, and there are several helpful PRs
that are now integrated intopytest-order. The idea and most of the
initial code has been created by Frank Tobia, the author of that plugin, andcontributors.While derived frompytest_ordering,pytest-orderisnotcompatible
withpytest-orderingdue to the changed marker name (orderinstead ofrun). Additional markers definedpytest_orderingare all integrated
into theordermarker (for a rationale see alsothis issue).Ordering relative to other tests and all the configuration options are not
available in the released version ofpytest-ordering.
However, most of these features are derived from or inspired byissuesand pull requests already existing inpytest-ordering.