Skip to content

Commit e716e25

Browse files
committed
Documentation updates
- more changes to pytest-ordering2 - some documenation consolidation, moved aspirational part (already implemented)
1 parent 063f864 commit e716e25

File tree

2 files changed

+49
-91
lines changed

2 files changed

+49
-91
lines changed

docs/source/conf.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# All configuration values have a default; values that are commented out
1313
# serve to show the default.
1414

15-
import sys
1615
import os
1716

1817
__here__ = os.path.abspath(os.path.dirname(__file__))
@@ -35,6 +34,7 @@
3534
'sphinx.ext.doctest',
3635
'sphinx.ext.coverage',
3736
'sphinx.ext.viewcode',
37+
'sphinx.ext.githubpages', # puts .nojekyll file into source
3838
]
3939

4040
# Add any paths that contain templates here, relative to this directory.
@@ -50,7 +50,7 @@
5050
master_doc = 'index'
5151

5252
# General information about the project.
53-
project = u'pytest-ordering'
53+
project = u'pytest-ordering2'
5454
copyright = u'2014, Frank Tobia'
5555

5656
# The version info for the project you're documenting, acts as replacement for
@@ -171,7 +171,7 @@
171171
#html_show_sourcelink = True
172172

173173
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
174-
#html_show_sphinx = True
174+
html_show_sphinx = False
175175

176176
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
177177
#html_show_copyright = True
@@ -205,7 +205,7 @@
205205
# (source start file, target name, title,
206206
# author, documentclass [howto, manual, or own class]).
207207
latex_documents = [
208-
('index', 'pytest-ordering.tex', u'pytest-ordering Documentation',
208+
('index', 'pytest-ordering.tex', u'pytest-ordering2 Documentation',
209209
u'Frank Tobia', 'manual'),
210210
]
211211

@@ -235,7 +235,7 @@
235235
# One entry per manual page. List of tuples
236236
# (source start file, name, description, authors, manual section).
237237
man_pages = [
238-
('index', 'pytest-ordering', u'pytest-ordering Documentation',
238+
('index', 'pytest-ordering2', u'pytest-ordering2 Documentation',
239239
[u'Frank Tobia'], 1)
240240
]
241241

@@ -249,8 +249,8 @@
249249
# (source start file, target name, title, author,
250250
# dir menu entry, description, category)
251251
texinfo_documents = [
252-
('index', 'pytest-ordering', u'pytest-ordering Documentation',
253-
u'Frank Tobia', 'pytest-ordering', 'One line description of project.',
252+
('index', 'pytest-ordering2', u'pytest-ordering2 Documentation',
253+
u'Frank Tobia', 'pytest-ordering2', 'One line description of project.',
254254
'Miscellaneous'),
255255
]
256256

docs/source/index.rst

Lines changed: 42 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,18 @@
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: run your tests in order
7-
=========================================
6+
pytest-ordering2: run your tests in order
7+
==========================================
88

9-
pytest-ordering is a pytest plugin to run your tests in any order that
9+
pytest-ordering2 is a pytest plugin to run your tests in any order that
1010
you specify. It provides custom markers_ that say when your tests should
1111
run in relation to each other. They can be absolute (i.e. first, or
1212
second-to-last) or relative (i.e. run this test before this other test).
1313

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-
Supported python and pytest versions
14+
Supported Python and pytest versions
2015
------------------------------------
2116

22-
pytest-ordering supports python 2.7, 3.4, 3.5, 3.6, 3.7, and pypy, and is
17+
pytest-ordering2 supports python 2.7, 3.5 - 3.8, and pypy, and is
2318
compatible with pytest 3.6.0 or newer.
2419

2520

@@ -57,11 +52,11 @@ With pytest-ordering, you can change the default ordering as follows:
5752
5853
import pytest
5954
60-
@pytest.mark.order2
55+
@pytest.mark.run(order=2)
6156
def test_foo():
6257
assert True
6358
64-
@pytest.mark.order1
59+
@pytest.mark..run(order=1)
6560
def test_bar():
6661
assert True
6762
@@ -79,29 +74,31 @@ With pytest-ordering, you can change the default ordering as follows:
7974
=========================== 2 passed in 0.01 seconds ===========================
8075

8176
This is a trivial example, but ordering is respected across test files.
77+
There are several possibilities to define the order.
8278

83-
Other markers
84-
-------------
85-
86-
You can also use markers such as "first", "second", "last", and "second_to_last":
79+
By number
80+
---------
81+
As already shown above, the order can be defined using ordinal numbers.
82+
Negative numbers are also allowed - they are used the same way as indexes
83+
used in Python lists, e.g. to count from the end:
8784

8885
.. code:: python
8986
9087
import pytest
9188
92-
@pytest.mark.second_to_last
89+
@pytest.mark.run(order=-2)
9390
def test_three():
9491
assert True
9592
96-
@pytest.mark.last
93+
@pytest.mark.run(order=-1)
9794
def test_four():
9895
assert True
9996
100-
@pytest.mark.second
97+
@pytest.mark.run(order=2)
10198
def test_two():
10299
assert True
103100
104-
@pytest.mark.first
101+
@pytest.mark.run(order=1)
105102
def test_one():
106103
assert True
107104
@@ -120,87 +117,31 @@ You can also use markers such as "first", "second", "last", and "second_to_last"
120117

121118
=========================== 4 passed in 0.02 seconds ===========================
122119

123-
``--indulgent-ordering`` and overriding ordering
124-
-------------
125-
126-
You may sometimes find that you want to suggest an ordering of tests, while
127-
allowing it to be overridden for good reson. For example, if you run your test
128-
suite in parallel and have a number of tests which are particularly slow, it
129-
might be desirable to start those tests running first, in order to optimize
130-
your completion time. You can use the pytest-ordering plugin to inform pytest
131-
of this. Now suppose you also want to prioritize tests which failed during the
132-
previous run, by using the ``--failed-first`` option. By default,
133-
pytest-ordering will override the ``--failed-first`` order, but by adding the
134-
``--indulgent-ordering`` option, you can ask pytest to run the sort from
135-
pytest-ordering *before* the sort from ``--failed-first``, allowing the failed
136-
tests to be sorted to the front.
137-
138-
139-
Aspirational
140-
============
141-
142-
This section is for functionality I'd like to implement.
143-
Documentation-driven design :)
144120

145121
Ordinals
146122
--------
147123

148-
.. code:: python
149-
150-
import pytest
151-
152-
@pytest.mark.run('second-to-last')
153-
def test_three():
154-
assert True
155-
156-
@pytest.mark.run('last')
157-
def test_four():
158-
assert True
159-
160-
@pytest.mark.run('second')
161-
def test_two():
162-
assert True
163-
164-
@pytest.mark.run('first')
165-
def test_one():
166-
assert True
167-
168-
::
169-
170-
$ py.test test_foo.py -vv
171-
============================= test session starts ==============================
172-
platform darwin -- Python 2.7.5 -- py-1.4.20 -- pytest-2.5.2 -- env/bin/python
173-
plugins: ordering
174-
collected 4 items
175-
176-
test_foo.py:17: test_one PASSED
177-
test_foo.py:12: test_two PASSED
178-
test_foo.py:3: test_three PASSED
179-
test_foo.py:7: test_four PASSED
180-
181-
=========================== 4 passed in 0.02 seconds ===========================
182-
183-
184-
By number
185-
---------
124+
You can also use markers such as "first", "second", "last", and
125+
"second_to_last". These are convenience notations, and have the same effect
126+
as the numbers 1, 2, -1 and -2 that have been shown above:
186127

187128
.. code:: python
188129
189130
import pytest
190131
191-
@pytest.mark.run(order=-2)
132+
@pytest.mark.second_to_last
192133
def test_three():
193134
assert True
194135
195-
@pytest.mark.run(order=-1)
136+
@pytest.mark.last
196137
def test_four():
197138
assert True
198139
199-
@pytest.mark.run(order=2)
140+
@pytest.mark.second
200141
def test_two():
201142
assert True
202143
203-
@pytest.mark.run(order=1)
144+
@pytest.mark.first
204145
def test_one():
205146
assert True
206147
@@ -219,10 +160,11 @@ By number
219160

220161
=========================== 4 passed in 0.02 seconds ===========================
221162

222-
223163
Relative to other tests
224164
-----------------------
225165

166+
The test order can be defined relative to other tests, which are referenced
167+
by their name:
226168

227169
.. code:: python
228170
@@ -253,6 +195,22 @@ Relative to other tests
253195

254196
=========================== 4 passed in 0.02 seconds ===========================
255197

198+
``--indulgent-ordering`` and overriding ordering
199+
------------------------------------------------
200+
201+
You may sometimes find that you want to suggest an ordering of tests, while
202+
allowing it to be overridden for good reason. For example, if you run your test
203+
suite in parallel and have a number of tests which are particularly slow, it
204+
might be desirable to start those tests running first, in order to optimize
205+
your completion time. You can use the pytest-ordering2 plugin to inform pytest
206+
of this.
207+
Now suppose you also want to prioritize tests which failed during the
208+
previous run, by using the ``--failed-first`` option. By default,
209+
pytest-ordering will override the ``--failed-first`` order, but by adding the
210+
``--indulgent-ordering`` option, you can ask pytest to run the sort from
211+
pytest-ordering2 *before* the sort from ``--failed-first``, allowing the failed
212+
tests to be sorted to the front.
213+
256214

257215

258216
.. toctree::

0 commit comments

Comments
 (0)