Skip to content

Commit e4ebccf

Browse files
committed
Better documentation, much of it aspirational.
1 parent 73f840a commit e4ebccf

File tree

1 file changed

+135
-4
lines changed

1 file changed

+135
-4
lines changed

docs/source/index.rst

Lines changed: 135 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,22 @@
33
You can adapt this file completely to your liking, but it should at least
44
contain the root `toctree` directive.
55
6-
pytest-ordering: pytest plugin to run your tests in a specific order
7-
====================================================================
6+
pytest-ordering: run your tests in order
7+
=========================================
88

9-
pytest-ordering provides custom markers_ that let you run your tests
10-
in any order you would like.
9+
pytest-ordering is a pytest plugin to run your tests in any order that
10+
you specify. It provides custom markers_ that say when your tests should
11+
run in relation to each other. They can be absolute (i.e. first, or
12+
second-to-last) or relative (i.e. run this test before this other test).
13+
14+
.. note :: pytest-ordering is currently alpha-quality software. Notably,
15+
some of this documentation may be aspirational in nature. If something
16+
you read here isn't currently implemented, rest assured that I am working
17+
on it (or feel free to ping me: https://github.com/ftobia)
18+
19+
20+
Quickstart
21+
----------
1122

1223
Ordinarily pytest will run tests in the order that they appear in a module.
1324
For example, for the following tests:
@@ -63,6 +74,9 @@ With pytest-ordering, you can change the default ordering as follows:
6374

6475
This is a trivial example, but ordering is respected across test files.
6576

77+
Other markers
78+
-------------
79+
6680
You can also use markers such as "first", "second", "last", and "second_to_last":
6781

6882
.. code:: python
@@ -101,6 +115,123 @@ You can also use markers such as "first", "second", "last", and "second_to_last"
101115
=========================== 4 passed in 0.02 seconds ===========================
102116

103117

118+
Aspirational
119+
============
120+
121+
This section is for functionality I'd like to implement.
122+
Documentation-driven design :)
123+
124+
Ordinals
125+
--------
126+
127+
.. code:: python
128+
129+
import pytest
130+
131+
@pytest.mark.run('second-to-last')
132+
def test_three():
133+
assert True
134+
135+
@pytest.mark.run('last')
136+
def test_four():
137+
assert True
138+
139+
@pytest.mark.run('second')
140+
def test_two():
141+
assert True
142+
143+
@pytest.mark.run('first')
144+
def test_one():
145+
assert True
146+
147+
::
148+
149+
$ py.test test_foo.py -vv
150+
============================= test session starts ==============================
151+
platform darwin -- Python 2.7.5 -- py-1.4.20 -- pytest-2.5.2 -- env/bin/python
152+
plugins: ordering
153+
collected 4 items
154+
155+
test_foo.py:17: test_one PASSED
156+
test_foo.py:12: test_two PASSED
157+
test_foo.py:3: test_three PASSED
158+
test_foo.py:7: test_four PASSED
159+
160+
=========================== 4 passed in 0.02 seconds ===========================
161+
162+
163+
By number
164+
---------
165+
166+
.. code:: python
167+
168+
import pytest
169+
170+
@pytest.mark.run(order=-2)
171+
def test_three():
172+
assert True
173+
174+
@pytest.mark.run(order=-1)
175+
def test_four():
176+
assert True
177+
178+
@pytest.mark.run(order=2)
179+
def test_two():
180+
assert True
181+
182+
@pytest.mark.run(order=1)
183+
def test_one():
184+
assert True
185+
186+
::
187+
188+
$ py.test test_foo.py -vv
189+
============================= test session starts ==============================
190+
platform darwin -- Python 2.7.5 -- py-1.4.20 -- pytest-2.5.2 -- env/bin/python
191+
plugins: ordering
192+
collected 4 items
193+
194+
test_foo.py:17: test_one PASSED
195+
test_foo.py:12: test_two PASSED
196+
test_foo.py:3: test_three PASSED
197+
test_foo.py:7: test_four PASSED
198+
199+
=========================== 4 passed in 0.02 seconds ===========================
200+
201+
202+
Relative to other tests
203+
-----------------------
204+
205+
206+
.. code:: python
207+
208+
import pytest
209+
210+
@pytest.mark.run(after='test_second')
211+
def test_third():
212+
assert True
213+
214+
def test_second():
215+
assert True
216+
217+
@pytest.mark.run(before='test_second')
218+
def test_first():
219+
assert True
220+
221+
::
222+
223+
$ py.test test_foo.py -vv
224+
============================= test session starts ==============================
225+
platform darwin -- Python 2.7.5 -- py-1.4.20 -- pytest-2.5.2 -- env/bin/python
226+
plugins: ordering
227+
collected 3 items
228+
229+
test_foo.py:11: test_first PASSED
230+
test_foo.py:7: test_second PASSED
231+
test_foo.py:4: test_third PASSED
232+
233+
=========================== 4 passed in 0.02 seconds ===========================
234+
104235

105236

106237
.. toctree::

0 commit comments

Comments
 (0)