Skip to content

Commit 4a43b3b

Browse files
committed
Add example files for all examples in documentation
1 parent e6aaf0d commit 4a43b3b

19 files changed

+179
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Documentation
2020
Apart from this overview, the following information is available:
2121
- usage documentation for the [latest release](https://mrbean-bremen.github.io/pytest-order/stable/)
2222
- usage documentation for the [current master](https://mrbean-bremen.github.io/pytest-order/dev/)
23+
- all examples shown in the documentation can also be found in the
24+
[repository](https://github.com/mrbean-bremen/pytest-order/tree/master/example)
2325
- the [Release Notes](https://github.com/mrbean-bremen/pytest-order/blob/master/CHANGELOG.md)
2426
with a list of changes in the latest versions
2527
- a [list of open issues](https://github.com/mrbean-bremen/pytest-order/blob/master/old_issues.md)

docs/source/index.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ The latest master can be installed from the GitHub sources:
6060
6161
pip install git+https://github.com/mrbean-bremen/pytest-order
6262
63+
Examples
64+
--------
65+
All examples shown in this documentation can be also found in the repository
66+
under `example <https://github.com/mrbean-bremen/pytest-order/tree/master/example/>`__
67+
as working test files.
68+
6369
Quickstart
6470
----------
6571
Ordinarily pytest will run tests in the order that they appear in a module.
@@ -301,14 +307,14 @@ with a ``::`` suffix has to be prepended to the test name:
301307
302308
class TestA:
303309
@pytest.mark.order(after="TestB::test_c")
304-
def test_a():
310+
def test_a(self):
305311
assert True
306312
307-
def test_b():
313+
def test_b(self):
308314
assert True
309315
310316
class TestB:
311-
def test_c():
317+
def test_c(self):
312318
assert True
313319
314320
If the referenced test lives in another module, the test name has to be
@@ -324,7 +330,7 @@ the following module and test layout:
324330
test_module_b.py
325331
test_a
326332
test_b
327-
test_module_c.py
333+
test_module_c
328334
test_submodule.py
329335
test_1
330336
test_2

example/__init__.py

Whitespace-only changes.

example/test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""Reference test without ordering from the quick start chapter.
2+
See https://mrbean-bremen.github.io/pytest-order/dev/#quickstart
3+
"""
4+
5+
16
def test_foo():
27
assert True
38

example/test_classes.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Shows how to use relative sorting in test classes, see
2+
See https://mrbean-bremen.github.io/pytest-order/dev/#referencing-of-tests-in-other-classes-or-modules # noqa: E501
3+
"""
4+
import pytest
5+
6+
7+
class TestA:
8+
@pytest.mark.order(after="TestB::test_c")
9+
def test_a(self):
10+
assert True
11+
12+
def test_b(self):
13+
assert True
14+
15+
16+
class TestB:
17+
def test_c(self):
18+
assert True

example/test_combined.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""Shows how combined ordinal and relative sorting is handled.
2+
See https://mrbean-bremen.github.io/pytest-order/dev/#combination-of-absolute-and-relative-ordering # noqa: E501
3+
"""
4+
import pytest
5+
6+
7+
@pytest.mark.order(index=0, after="test_second")
8+
def test_first():
9+
assert True
10+
11+
12+
@pytest.mark.order(1)
13+
def test_second():
14+
assert True

example/test_module1.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""One of the test files showing the use of the --order-scope option.
2+
See https://mrbean-bremen.github.io/pytest-order/dev/#order-scope
3+
"""
4+
import pytest
5+
6+
7+
@pytest.mark.order(2)
8+
def test2():
9+
pass
10+
11+
12+
@pytest.mark.order(1)
13+
def test1():
14+
pass

example/test_module2.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""One of the test files showing the use of the --order-scope option.
2+
See https://mrbean-bremen.github.io/pytest-order/dev/#order-scope
3+
"""
4+
import pytest
5+
6+
7+
@pytest.mark.order(2)
8+
def test2():
9+
pass
10+
11+
12+
@pytest.mark.order(1)
13+
def test1():
14+
pass

example/test_module_a.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""One of the example files showing relative ordering between modules.
2+
See https://mrbean-bremen.github.io/pytest-order/dev/#referencing-of-tests-in-other-classes-or-modules # noqa: E501
3+
"""
4+
5+
6+
class TestA:
7+
def test_a(self):
8+
assert True
9+
10+
def test_b(self):
11+
assert True

example/test_module_c/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)