pytest plugin to run your tests in a specific order
Project description
pytest-order - a pytest plugin to order test execution
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:
- usage documentation for the latest release
- usage documentation for the current main branch
- all examples shown in the documentation can also be found in the repository
- the Release Notes with a list of changes in the latest versions
- a list of open issues
in the original project and their handling in
pytest-order
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
andafter
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 theorder-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
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
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest_order-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4cdf12f4c83c76bdfd6e6088e2e157df7fdf91a9c3e3ca7d8809e8dabce0f4b |
|
MD5 | f8b8fca942c3df6a2c37e29094c3117d |
|
BLAKE2b-256 | 502bfd034b3423bb1b65906513f43402f4d717c9443e561ed569f80fc57c5a84 |