Skip to content

Commit a8eb561

Browse files
committed
Add pytest-xdist regression test
- imported from PR #52, by Andrew Gilbert - adapt xdist-versions supported for different pytest versions - do not run xdist test for Python 3.10.1 due to an unrelated problem with that version
1 parent 4c34fbb commit a8eb561

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
- added automatic documentation build on change
1010
- add Python 3.9, pypy3 and pytest 6.0 and 6.1 to CI builds
1111
- use GitHub Actions for builds, add Windows builds
12+
- add regression test for ``pytest-xdist``
13+
(imported from [PR #52](https://github.com/ftobia/pytest-ordering/pull/52))
1214

1315
## [Version 0.7.1](https://pypi.org/project/pytest-order/0.7.1/)
1416
Update after renaming the repository and the package.

tests/test_xdist_handling.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import pytest
4+
import pytest_order
5+
6+
pytest_plugins = ['pytester']
7+
8+
9+
@pytest.mark.skipif(pytest.__version__ == "3.10.1",
10+
reason="That version seems to have a parser problem")
11+
def test_xdist_ordering(tmpdir):
12+
testname = str(tmpdir.join("first_test.py"))
13+
with open(testname, "w") as fi:
14+
fi.write(
15+
"""
16+
import pytest
17+
18+
val = 1
19+
20+
@pytest.mark.order("second")
21+
def test_second_integer():
22+
global val
23+
assert val == 2
24+
val += 1
25+
26+
def test_last_integer():
27+
assert val == 3
28+
29+
@pytest.mark.order("first")
30+
def test_first_integer():
31+
global val
32+
assert val == 1
33+
val += 1
34+
"""
35+
)
36+
37+
testname = str(tmpdir.join("second_test.py"))
38+
with open(testname, "w") as fi:
39+
fi.write(
40+
"""
41+
import pytest
42+
43+
val = "frog"
44+
45+
@pytest.mark.order("second")
46+
def test_second_string():
47+
global val
48+
assert val == "goat"
49+
val = "fish"
50+
51+
def test_last_string():
52+
assert val == "fish"
53+
54+
@pytest.mark.order("first")
55+
def test_first_string():
56+
global val
57+
assert val == "frog"
58+
val = "goat"
59+
"""
60+
)
61+
# With `loadfile`, the tests should pass
62+
args = ["-n3", "--dist=loadfile", str(tmpdir)]
63+
ret = pytest.main(args, [pytest_order])
64+
assert ret == 0
65+
66+
# Without `loadfile`, the tests should fail
67+
args = ["-n3", str(tmpdir)]
68+
ret = pytest.main(args, [pytest_order])
69+
assert ret == 1

tox.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ deps =
2626
pytest61: pytest>=6.1,<6.2
2727
pytest{40,41,42}: attrs<19.2
2828
pytest-cov<2.10
29+
pytest{36}: pytest-forked<1.3.0
30+
pytest{36,37,38,39,40,41,42,43}: pytest-xdist<1.28.0
31+
pytest{44,45,46,50,51,52,53,54}: pytest-xdist<2.0.0
32+
pytest{60,61}: pytest-xdist
2933

3034
commands =
3135
coverage run --source=pytest_order -m pytest tests

0 commit comments

Comments
 (0)