1
1
pytest-order: run your tests in order
2
- ==========================================
3
-
2
+ ======================================
4
3
pytest-order is a pytest plugin to run your tests in any order that
5
4
you specify. It provides the marker ``order ``, that defines when your tests
6
5
should run in relation to each other. They can be absolute (i.e. first, or
7
6
second-to-last) or relative (i.e. run this test before this other test).
8
7
8
+ Relationship with pytest-ordering
9
+ ---------------------------------
10
+ ``pytest-order `` is a fork of
11
+ `pytest-ordering <https://github.com/ftobia/pytest-ordering >`__, which is
12
+ not maintained anymore. The idea and most of the code has been created by
13
+ Frank Tobia, the author of that plugin.
14
+
15
+ However, ``pytest-order `` is not compatible with ``pytest-ordering `` due to the
16
+ changed marker name (``order `` instead of ``run ``) and the removal of all
17
+ other special markers for consistence (see
18
+ `this issue <https://github.com/ftobia/pytest-ordering/issues/38 >`__). This
19
+ also avoids clashes between the plugins if they are both installed.
20
+
21
+ Here are examples for which markers correspond to markers in
22
+ ``pytest-ordering ``:
23
+
24
+ - ``pytest.mark.order1 ``, ``pytest.mark.run(order=1) `` => ``pytest.mark.order(1) ``
25
+ - ``pytest.mark.first `` => ``pytest.mark.order("first") ``
26
+
27
+
9
28
Supported Python and pytest versions
10
29
------------------------------------
11
-
12
30
pytest-order supports python 2.7, 3.5 - 3.8, and pypy, and is
13
- compatible with pytest 3.6.0 or newer.
31
+ compatible with pytest 3.6.0 or newer. Note that support for Python 2 will
32
+ be removed in one of the next versions.
14
33
34
+ Installation
35
+ ------------
36
+ The latest released version can be installed from
37
+ `PyPi <https://pypi.python.org/pypi/pytest-order/ >`__:
38
+
39
+ .. code :: bash
40
+
41
+ pip install pytest-order
42
+
43
+ The latest master can be installed from the GitHub sources:
44
+
45
+ .. code :: bash
46
+
47
+ pip install git+https://github.com/mrbean-bremen/pytest-order
15
48
16
49
Quickstart
17
50
----------
18
-
19
51
Ordinarily pytest will run tests in the order that they appear in a module.
20
52
For example, for the following tests:
21
53
@@ -33,7 +65,7 @@ Here is the output:
33
65
34
66
$ py.test test_foo.py -vv
35
67
============================= test session starts ==============================
36
- platform darwin -- Python 2 .7.5 -- py-1.4.20 -- pytest-2.5.2 -- env/bin/python
68
+ platform darwin -- Python 3 .7.1, pytest-5.4.3, py-1.8.1, pluggy-0.13.1 -- env/bin/python
37
69
collected 2 items
38
70
39
71
test_foo.py:2: test_foo PASSED
@@ -59,8 +91,8 @@ With pytest-order, you can change the default ordering as follows:
59
91
60
92
$ py.test test_foo.py -vv
61
93
============================= test session starts ==============================
62
- platform darwin -- Python 2 .7.5 -- py-1.4.20 -- pytest-2.5.2 -- env/bin/python
63
- plugins: ordering
94
+ platform darwin -- Python 3 .7.1, pytest-5.4.3, py-1.8.1, pluggy-0.13.1 -- env/bin/python
95
+ plugins: order
64
96
collected 2 items
65
97
66
98
test_foo.py:7: test_bar PASSED
@@ -101,8 +133,8 @@ are used in Python lists, e.g. to count from the end:
101
133
102
134
$ py.test test_foo.py -vv
103
135
============================= test session starts ==============================
104
- platform darwin -- Python 2 .7.5 -- py-1.4.20 -- pytest-2.5.2 -- env/bin/python
105
- plugins: ordering
136
+ platform darwin -- Python 3 .7.1, pytest-5.4.3, py-1.8.1, pluggy-0.13.1 -- env/bin/python
137
+ plugins: order
106
138
collected 4 items
107
139
108
140
test_foo.py:17: test_one PASSED
@@ -144,8 +176,8 @@ as the numbers 1, 2, -1 and -2 that have been shown above:
144
176
145
177
$ py.test test_foo.py -vv
146
178
============================= test session starts ==============================
147
- platform darwin -- Python 2 .7.5 -- py-1.4.20 -- pytest-2.5.2 -- env/bin/python
148
- plugins: ordering
179
+ platform darwin -- Python 3 .7.1, pytest-5.4.3, py-1.8.1, pluggy-0.13.1 -- env/bin/python
180
+ plugins: order
149
181
collected 4 items
150
182
151
183
test_foo.py:17: test_one PASSED
@@ -180,8 +212,8 @@ by their name:
180
212
181
213
$ py.test test_foo.py -vv
182
214
============================= test session starts ==============================
183
- platform darwin -- Python 2 .7.5 -- py-1.4.20 -- pytest-2.5.2 -- env/bin/python
184
- plugins: ordering
215
+ platform darwin -- Python 3 .7.1, pytest-5.4.3, py-1.8.1, pluggy-0.13.1 -- env/bin/python
216
+ plugins: order
185
217
collected 3 items
186
218
187
219
test_foo.py:11: test_first PASSED
0 commit comments