1212
1313@pytest .mark .parametrize ("mode" , ["normal" , "xdist" ])
1414class TestFixture :
15- """
16- Tests for ``subtests`` fixture.
17- """
15+ """Tests for ``subtests`` fixture."""
1816
1917 @pytest .fixture
2018 def simple_script (self , pytester : pytest .Pytester ) -> None :
@@ -39,7 +37,7 @@ def test_simple_terminal_normal(
3937 else :
4038 assert mode == "xdist"
4139 pytest .importorskip ("xdist" )
42- result = pytester .runpytest ("-n1" )
40+ result = pytester .runpytest ("-n1" , "-pxdist.plugin" )
4341 expected_lines = ["1 worker [1 item]" ]
4442
4543 expected_lines += [
@@ -69,7 +67,7 @@ def test_simple_terminal_verbose(
6967 else :
7068 assert mode == "xdist"
7169 pytest .importorskip ("xdist" )
72- result = pytester .runpytest ("-n1" , "-v" )
70+ result = pytester .runpytest ("-n1" , "-v" , "-pxdist.plugin" )
7371 expected_lines = [
7472 "1 worker [1 item]" ,
7573 "*gw0*100%* test_simple_terminal_verbose.py::test_foo*" ,
@@ -106,7 +104,7 @@ def test_foo(subtests):
106104 else :
107105 assert mode == "xdist"
108106 pytest .importorskip ("xdist" )
109- result = pytester .runpytest ("-n1" )
107+ result = pytester .runpytest ("-n1" , "-pxdist.plugin" )
110108 expected_lines = ["1 worker [1 item]" ]
111109 expected_lines += ["* 1 passed, 3 skipped, 2 subtests passed in *" ]
112110 result .stdout .fnmatch_lines (expected_lines )
@@ -130,7 +128,7 @@ def test_foo(subtests):
130128 else :
131129 assert mode == "xdist"
132130 pytest .importorskip ("xdist" )
133- result = pytester .runpytest ("-n1" )
131+ result = pytester .runpytest ("-n1" , "-pxdist.plugin" )
134132 expected_lines = ["1 worker [1 item]" ]
135133 expected_lines += ["* 1 passed, 2 subtests passed, 3 subtests xfailed in *" ]
136134 result .stdout .fnmatch_lines (expected_lines )
@@ -152,7 +150,7 @@ def test_typing_exported(subtests: SubTests) -> None:
152150 else :
153151 assert mode == "xdist"
154152 pytest .importorskip ("xdist" )
155- result = pytester .runpytest ("-n1" )
153+ result = pytester .runpytest ("-n1" , "-pxdist.plugin" )
156154 expected_lines = ["1 worker [1 item]" ]
157155 expected_lines += ["* 1 passed *" ]
158156 result .stdout .fnmatch_lines (expected_lines )
@@ -215,9 +213,7 @@ def test_foo(subtests):
215213
216214
217215class TestSubTest :
218- """
219- Test Test.subTest functionality.
220- """
216+ """Test.subTest functionality."""
221217
222218 @pytest .fixture
223219 def simple_script (self , pytester : pytest .Pytester ) -> Path :
@@ -264,11 +260,11 @@ def test_simple_terminal_normal(
264260 else :
265261 assert runner == "pytest-xdist"
266262 pytest .importorskip ("xdist" )
267- result = pytester .runpytest (simple_script , "-n1" )
263+ result = pytester .runpytest (simple_script , "-n1" , "-pxdist.plugin" )
268264 expected_lines = ["1 worker [1 item]" ]
269265 result .stdout .fnmatch_lines (
270- expected_lines
271- + [
266+ [
267+ * expected_lines ,
272268 "* T.test_foo [[]custom[]] (i=1) *" ,
273269 "E * AssertionError: 1 != 0" ,
274270 "* T.test_foo [[]custom[]] (i=3) *" ,
@@ -310,16 +306,18 @@ def test_simple_terminal_verbose(
310306 else :
311307 assert runner == "pytest-xdist"
312308 pytest .importorskip ("xdist" )
313- result = pytester .runpytest (simple_script , "-n1" , "-v" )
309+ result = pytester .runpytest (
310+ simple_script , "-n1" , "-v" , "-pxdist.plugin"
311+ )
314312 expected_lines = [
315313 "1 worker [1 item]" ,
316314 "*gw0*100%* SUBFAIL test_simple_terminal_verbose.py::T::test_foo*" ,
317315 "*gw0*100%* SUBFAIL test_simple_terminal_verbose.py::T::test_foo*" ,
318316 "*gw0*100%* PASSED test_simple_terminal_verbose.py::T::test_foo*" ,
319317 ]
320318 result .stdout .fnmatch_lines (
321- expected_lines
322- + [
319+ [
320+ * expected_lines ,
323321 "* T.test_foo [[]custom[]] (i=1) *" ,
324322 "E * AssertionError: 1 != 0" ,
325323 "* T.test_foo [[]custom[]] (i=3) *" ,
@@ -470,15 +468,19 @@ def test_foo(self):
470468 result = pytester .runpytest (p , "-v" , "-rsf" )
471469 result .stdout .re_match_lines (
472470 [
473- r"test_skip_with_failure.py::T::test_foo \[custom message\] \(i=0\) SUBSKIP \(skip subtest i=0\) .*" ,
474- r"test_skip_with_failure.py::T::test_foo \[custom message\] \(i=3\) SUBSKIP \(skip subtest i=3\) .*" ,
471+ r"test_skip_with_failure.py::T::test_foo \[custom message\] \(i=0\) SUBSKIP"
472+ r" \(skip subtest i=0\) .*" ,
473+ r"test_skip_with_failure.py::T::test_foo \[custom message\] \(i=3\) SUBSKIP"
474+ r" \(skip subtest i=3\) .*" ,
475475 r"test_skip_with_failure.py::T::test_foo \[custom message\] \(i=4\) SUBFAIL .*" ,
476476 r"test_skip_with_failure.py::T::test_foo \[custom message\] \(i=9\) SUBFAIL .*" ,
477477 "test_skip_with_failure.py::T::test_foo PASSED .*" ,
478478 r"[custom message] (i=0) SUBSKIP [1] test_skip_with_failure.py:5: skip subtest i=0" ,
479479 r"[custom message] (i=0) SUBSKIP [1] test_skip_with_failure.py:5: skip subtest i=3" ,
480- r"[custom message] (i=4) SUBFAIL test_skip_with_failure.py::T::test_foo - AssertionError: assert 4 < 4" ,
481- r"[custom message] (i=9) SUBFAIL test_skip_with_failure.py::T::test_foo - AssertionError: assert 9 < 4" ,
480+ r"[custom message] (i=4) SUBFAIL test_skip_with_failure.py::T::test_foo"
481+ r" - AssertionError: assert 4 < 4" ,
482+ r"[custom message] (i=9) SUBFAIL test_skip_with_failure.py::T::test_foo"
483+ r" - AssertionError: assert 9 < 4" ,
482484 r".* 6 failed, 1 passed, 4 skipped in .*" ,
483485 ]
484486 )
@@ -542,8 +544,10 @@ def test_foo(self):
542544 [
543545 r"test_skip_with_failure_and_non_subskip.py::T::test_foo \[custom message\] \(i=4\) SUBFAIL .*" ,
544546 r"test_skip_with_failure_and_non_subskip.py::T::test_foo SKIPPED \(skip the test\)" ,
545- r"\[custom message\] \(i=0\) SUBSKIP \[1\] test_skip_with_failure_and_non_subskip.py:5: skip subtest i=3" ,
546- r"\[custom message\] \(i=0\) SUBSKIP \[1\] test_skip_with_failure_and_non_subskip.py:5: skip the test" ,
547+ r"\[custom message\] \(i=0\) SUBSKIP \[1\] test_skip_with_failure_and_non_subskip.py:5:"
548+ r" skip subtest i=3" ,
549+ r"\[custom message\] \(i=0\) SUBSKIP \[1\] test_skip_with_failure_and_non_subskip.py:5:"
550+ r" skip the test" ,
547551 r"\[custom message\] \(i=4\) SUBFAIL test_skip_with_failure_and_non_subskip.py::T::test_foo" ,
548552 r".* 6 failed, 5 skipped in .*" ,
549553 ]
@@ -555,7 +559,8 @@ def test_foo(self):
555559 [
556560 r"test_skip_with_failure_and_non_subskip.py::T::test_foo \[custom message\] \(i=4\) SUBFAIL .*" ,
557561 r"test_skip_with_failure_and_non_subskip.py::T::test_foo SKIPPED \(skip the test\).*" ,
558- r"\[custom message\] \(i=3\) SUBSKIP test_skip_with_failure_and_non_subskip.py::T::test_foo - Skipped: skip subtest i=3" ,
562+ r"\[custom message\] \(i=3\) SUBSKIP test_skip_with_failure_and_non_subskip.py::T::test_foo"
563+ r" - Skipped: skip subtest i=3" ,
559564 r"SKIPPED test_skip_with_failure_and_non_subskip.py::T::test_foo - Skipped: skip the test" ,
560565 r"\[custom message\] \(i=4\) SUBFAIL test_skip_with_failure_and_non_subskip.py::T::test_foo" ,
561566 r".* 6 failed, 5 skipped in .*" ,
@@ -748,9 +753,7 @@ class TestDebugging:
748753 """Check --pdb support for subtests fixture and TestCase.subTest."""
749754
750755 class _FakePdb :
751- """
752- Fake debugger class implementation that tracks which methods were called on it.
753- """
756+ """Fake debugger class implementation that tracks which methods were called on it."""
754757
755758 quitting : bool = False
756759 calls : list [str ] = []
@@ -813,9 +816,7 @@ def runpytest_and_check_pdb(
813816
814817
815818def test_exitfirst (pytester : pytest .Pytester ) -> None :
816- """
817- Validate that when passing --exitfirst the test exits after the first failed subtest.
818- """
819+ """Validate that when passing --exitfirst the test exits after the first failed subtest."""
819820 pytester .makepyfile (
820821 """
821822 def test_foo(subtests):
0 commit comments