Skip to content

Commit 9d74881

Browse files
committed
Minimal docs to get us off the ground.
1 parent bc9f87f commit 9d74881

File tree

1 file changed

+98
-10
lines changed

1 file changed

+98
-10
lines changed

docs/source/index.rst

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

9-
Contents:
9+
pytest-ordering provides custom markers_ that let you run your tests
10+
in any order you would like.
1011

11-
.. toctree::
12-
:maxdepth: 2
12+
Ordinarily pytest will run tests in the order that they appear in a module.
13+
For example, for the following tests:
14+
15+
.. code:: python
16+
17+
def test_foo():
18+
assert True
19+
20+
def test_bar():
21+
assert True
22+
23+
Here is the output:
24+
25+
::
26+
27+
$ py.test test_foo.py -vv
28+
============================= test session starts ==============================
29+
platform darwin -- Python 2.7.5 -- py-1.4.20 -- pytest-2.5.2 -- env/bin/python
30+
collected 2 items
31+
32+
test_foo.py:2: test_foo PASSED
33+
test_foo.py:6: test_bar PASSED
34+
35+
=========================== 2 passed in 0.01 seconds ===========================
36+
37+
With pytest-ordering, you can change the default ordering as follows:
38+
39+
.. code:: python
40+
41+
import pytest
42+
43+
@pytest.mark.order2
44+
def test_foo():
45+
assert True
46+
47+
@pytest.mark.order1
48+
def test_bar():
49+
assert True
50+
51+
::
52+
53+
$ py.test test_foo.py -vv
54+
============================= test session starts ==============================
55+
platform darwin -- Python 2.7.5 -- py-1.4.20 -- pytest-2.5.2 -- env/bin/python
56+
plugins: ordering
57+
collected 2 items
1358

59+
test_foo.py:7: test_bar PASSED
60+
test_foo.py:3: test_foo PASSED
1461

62+
=========================== 2 passed in 0.01 seconds ===========================
1563

16-
Indices and tables
17-
==================
64+
This is a trivial example, but ordering is respected across test files.
65+
66+
You can also use markers such as "first", "second", "last", and "second_to_last":
67+
68+
.. code:: python
69+
70+
import pytest
71+
72+
@pytest.mark.second_to_last
73+
def test_three():
74+
assert True
75+
76+
@pytest.mark.last
77+
def test_four():
78+
assert True
79+
80+
@pytest.mark.second
81+
def test_two():
82+
assert True
83+
84+
@pytest.mark.first
85+
def test_one():
86+
assert True
87+
88+
::
89+
90+
$ py.test test_foo.py -vv
91+
============================= test session starts ==============================
92+
platform darwin -- Python 2.7.5 -- py-1.4.20 -- pytest-2.5.2 -- env/bin/python
93+
plugins: ordering
94+
collected 4 items
95+
96+
test_foo.py:17: test_one PASSED
97+
test_foo.py:12: test_two PASSED
98+
test_foo.py:3: test_three PASSED
99+
test_foo.py:7: test_four PASSED
100+
101+
=========================== 4 passed in 0.02 seconds ===========================
102+
103+
104+
105+
106+
.. toctree::
107+
:maxdepth: 2
18108

19-
* :ref:`genindex`
20-
* :ref:`modindex`
21-
* :ref:`search`
109+
.. _markers: https://pytest.org/latest/mark.html
22110

0 commit comments

Comments
 (0)