Skip to content

Commit 0930889

Browse files
committed
Adapt matching of expected output in the tests to adapt to changes in
pytest 6.2.0 and newer, fix #50
1 parent 7a4f8b7 commit 0930889

9 files changed

+123
-123
lines changed

tests/test_02_simple_dependency.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ def test_d():
2929
""")
3030
result = ctestdir.runpytest("--verbose")
3131
result.assert_outcomes(passed=3, skipped=1, failed=0)
32-
result.stdout.fnmatch_lines("""
33-
*::test_a SKIPPED
34-
*::test_b PASSED
35-
*::test_c PASSED
36-
*::test_d PASSED
32+
result.stdout.re_match_lines(r"""
33+
.*::test_a SKIPPED(?:\s+\(.*\))?
34+
.*::test_b PASSED
35+
.*::test_c PASSED
36+
.*::test_d PASSED
3737
""")
3838

3939

@@ -62,11 +62,11 @@ def test_d():
6262
""")
6363
result = ctestdir.runpytest("--verbose")
6464
result.assert_outcomes(passed=1, skipped=3, failed=0)
65-
result.stdout.fnmatch_lines("""
66-
*::test_a PASSED
67-
*::test_b SKIPPED
68-
*::test_c SKIPPED
69-
*::test_d SKIPPED
65+
result.stdout.re_match_lines(r"""
66+
.*::test_a PASSED
67+
.*::test_b SKIPPED(?:\s+\(.*\))?
68+
.*::test_c SKIPPED(?:\s+\(.*\))?
69+
.*::test_d SKIPPED(?:\s+\(.*\))?
7070
""")
7171

7272

@@ -95,11 +95,11 @@ def test_d():
9595
""")
9696
result = ctestdir.runpytest("--verbose")
9797
result.assert_outcomes(passed=1, skipped=2, failed=1)
98-
result.stdout.fnmatch_lines("""
99-
*::test_a PASSED
100-
*::test_b FAILED
101-
*::test_c SKIPPED
102-
*::test_d SKIPPED
98+
result.stdout.re_match_lines(r"""
99+
.*::test_a PASSED
100+
.*::test_b FAILED
101+
.*::test_c SKIPPED(?:\s+\(.*\))?
102+
.*::test_d SKIPPED(?:\s+\(.*\))?
103103
""")
104104

105105

@@ -127,11 +127,11 @@ def test_d():
127127
""")
128128
result = ctestdir.runpytest("--verbose")
129129
result.assert_outcomes(passed=1, skipped=2, failed=1)
130-
result.stdout.fnmatch_lines("""
131-
*::test_a PASSED
132-
*::test_b FAILED
133-
*::test_c SKIPPED
134-
*::test_d SKIPPED
130+
result.stdout.re_match_lines(r"""
131+
.*::test_a PASSED
132+
.*::test_b FAILED
133+
.*::test_c SKIPPED(?:\s+\(.*\))?
134+
.*::test_d SKIPPED(?:\s+\(.*\))?
135135
""")
136136

137137

@@ -162,8 +162,8 @@ def test_d():
162162
""")
163163
result = ctestdir.runpytest("--verbose", "test_explicit_select.py::test_d")
164164
result.assert_outcomes(passed=0, skipped=1, failed=0)
165-
result.stdout.fnmatch_lines("""
166-
*::test_d SKIPPED
165+
result.stdout.re_match_lines(r"""
166+
.*::test_d SKIPPED(?:\s+\(.*\))?
167167
""")
168168

169169

@@ -195,9 +195,9 @@ def test_d():
195195
""")
196196
result = ctestdir.runpytest("--verbose")
197197
result.assert_outcomes(passed=3, skipped=1, failed=0)
198-
result.stdout.fnmatch_lines("""
199-
*::test_a PASSED
200-
*::test_b PASSED
201-
*::test_c PASSED
202-
*::test_d SKIPPED
198+
result.stdout.re_match_lines(r"""
199+
.*::test_a PASSED
200+
.*::test_b PASSED
201+
.*::test_c PASSED
202+
.*::test_d SKIPPED(?:\s+\(.*\))?
203203
""")

tests/test_03_class.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ def test_e(self):
3636
""")
3737
result = ctestdir.runpytest("--verbose")
3838
result.assert_outcomes(passed=2, skipped=2, failed=1)
39-
result.stdout.fnmatch_lines("""
40-
*::TestClass::test_a FAILED
41-
*::TestClass::test_b PASSED
42-
*::TestClass::test_c SKIPPED
43-
*::TestClass::test_d PASSED
44-
*::TestClass::test_e SKIPPED
39+
result.stdout.re_match_lines(r"""
40+
.*::TestClass::test_a FAILED
41+
.*::TestClass::test_b PASSED
42+
.*::TestClass::test_c SKIPPED(?:\s+\(.*\))?
43+
.*::TestClass::test_d PASSED
44+
.*::TestClass::test_e SKIPPED(?:\s+\(.*\))?
4545
""")
4646

4747

@@ -76,12 +76,12 @@ def test_e(self):
7676
""")
7777
result = ctestdir.runpytest("--verbose")
7878
result.assert_outcomes(passed=2, skipped=2, failed=1)
79-
result.stdout.fnmatch_lines("""
80-
*::TestClassNamed::test_a FAILED
81-
*::TestClassNamed::test_b PASSED
82-
*::TestClassNamed::test_c SKIPPED
83-
*::TestClassNamed::test_d PASSED
84-
*::TestClassNamed::test_e SKIPPED
79+
result.stdout.re_match_lines(r"""
80+
.*::TestClassNamed::test_a FAILED
81+
.*::TestClassNamed::test_b PASSED
82+
.*::TestClassNamed::test_c SKIPPED(?:\s+\(.*\))?
83+
.*::TestClassNamed::test_d PASSED
84+
.*::TestClassNamed::test_e SKIPPED(?:\s+\(.*\))?
8585
""")
8686

8787

@@ -114,8 +114,8 @@ def test_b():
114114
""")
115115
result = ctestdir.runpytest("--verbose")
116116
result.assert_outcomes(passed=1, skipped=1, failed=1)
117-
result.stdout.fnmatch_lines("""
118-
*::test_a FAILED
119-
*::TestClass::test_a PASSED
120-
*::test_b SKIPPED
117+
result.stdout.re_match_lines(r"""
118+
.*::test_a FAILED
119+
.*::TestClass::test_a PASSED
120+
.*::test_b SKIPPED(?:\s+\(.*\))?
121121
""")

tests/test_03_multiple_dependency.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ def test_k():
5454
""")
5555
result = ctestdir.runpytest("--verbose")
5656
result.assert_outcomes(passed=5, skipped=5, failed=1)
57-
result.stdout.fnmatch_lines("""
58-
*::test_a SKIPPED
59-
*::test_b FAILED
60-
*::test_c PASSED
61-
*::test_d PASSED
62-
*::test_e PASSED
63-
*::test_f SKIPPED
64-
*::test_g SKIPPED
65-
*::test_h PASSED
66-
*::test_i SKIPPED
67-
*::test_j PASSED
68-
*::test_k SKIPPED
57+
result.stdout.re_match_lines(r"""
58+
.*::test_a SKIPPED(?:\s+\(.*\))?
59+
.*::test_b FAILED
60+
.*::test_c PASSED
61+
.*::test_d PASSED
62+
.*::test_e PASSED
63+
.*::test_f SKIPPED(?:\s+\(.*\))?
64+
.*::test_g SKIPPED(?:\s+\(.*\))?
65+
.*::test_h PASSED
66+
.*::test_i SKIPPED(?:\s+\(.*\))?
67+
.*::test_j PASSED
68+
.*::test_k SKIPPED(?:\s+\(.*\))?
6969
""")

tests/test_03_param.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ def test_c(w):
4040
""")
4141
result = ctestdir.runpytest("--verbose")
4242
result.assert_outcomes(passed=7, skipped=5, failed=1)
43-
result.stdout.fnmatch_lines("""
44-
*::test_a?0-0? PASSED
45-
*::test_a?0-1? PASSED
46-
*::test_a?1-0? PASSED
47-
*::test_a?1-1? FAILED
48-
*::test_b?1-2? PASSED
49-
*::test_b?1-3? PASSED
50-
*::test_b?1-4? SKIPPED
51-
*::test_b?2-3? PASSED
52-
*::test_b?2-4? SKIPPED
53-
*::test_b?3-4? SKIPPED
54-
*::test_c?1? SKIPPED
55-
*::test_c?2? SKIPPED
56-
*::test_c?3? PASSED
43+
result.stdout.re_match_lines(r"""
44+
.*::test_a\[0-0\] PASSED
45+
.*::test_a\[0-1\] PASSED
46+
.*::test_a\[1-0\] PASSED
47+
.*::test_a\[1-1\] FAILED
48+
.*::test_b\[1-2\] PASSED
49+
.*::test_b\[1-3\] PASSED
50+
.*::test_b\[1-4\] SKIPPED(?:\s+\(.*\))?
51+
.*::test_b\[2-3\] PASSED
52+
.*::test_b\[2-4\] SKIPPED(?:\s+\(.*\))?
53+
.*::test_b\[3-4\] SKIPPED(?:\s+\(.*\))?
54+
.*::test_c\[1\] SKIPPED(?:\s+\(.*\))?
55+
.*::test_c\[2\] SKIPPED(?:\s+\(.*\))?
56+
.*::test_c\[3\] PASSED
5757
""")

tests/test_03_runtime.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ def test_d(request):
3232
""")
3333
result = ctestdir.runpytest("--verbose")
3434
result.assert_outcomes(passed=1, skipped=3, failed=0)
35-
result.stdout.fnmatch_lines("""
36-
*::test_a PASSED
37-
*::test_b SKIPPED
38-
*::test_c SKIPPED
39-
*::test_d SKIPPED
35+
result.stdout.re_match_lines(r"""
36+
.*::test_a PASSED
37+
.*::test_b SKIPPED(?:\s+\(.*\))?
38+
.*::test_c SKIPPED(?:\s+\(.*\))?
39+
.*::test_d SKIPPED(?:\s+\(.*\))?
4040
""")

tests/test_03_scope.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ def test_e():
3333
""")
3434
result = ctestdir.runpytest("--verbose")
3535
result.assert_outcomes(passed=2, skipped=2, failed=1)
36-
result.stdout.fnmatch_lines("""
36+
result.stdout.re_match_lines(r"""
3737
test_scope_module.py::test_a FAILED
3838
test_scope_module.py::test_b PASSED
39-
test_scope_module.py::test_c SKIPPED
39+
test_scope_module.py::test_c SKIPPED(?:\s+\(.*\))?
4040
test_scope_module.py::test_d PASSED
41-
test_scope_module.py::test_e SKIPPED
41+
test_scope_module.py::test_e SKIPPED(?:\s+\(.*\))?
4242
""")
4343

4444
def test_scope_session(ctestdir):
@@ -102,14 +102,14 @@ def test_h():
102102
""")
103103
result = ctestdir.runpytest("--verbose")
104104
result.assert_outcomes(passed=6, skipped=1, failed=2)
105-
result.stdout.fnmatch_lines("""
105+
result.stdout.re_match_lines(r"""
106106
test_scope_session_01.py::test_a PASSED
107107
test_scope_session_01.py::test_b FAILED
108108
test_scope_session_01.py::test_c PASSED
109109
test_scope_session_01.py::TestClass::test_b PASSED
110110
test_scope_session_02.py::test_a FAILED
111111
test_scope_session_02.py::test_e PASSED
112-
test_scope_session_02.py::test_f SKIPPED
112+
test_scope_session_02.py::test_f SKIPPED(?:\s+\(.*\))?
113113
test_scope_session_02.py::test_g PASSED
114114
test_scope_session_02.py::test_h PASSED
115115
""")
@@ -174,14 +174,14 @@ def test_h():
174174
ctestdir.makepyfile(**srcs)
175175
result = ctestdir.runpytest("--verbose")
176176
result.assert_outcomes(passed=4, skipped=2, failed=1)
177-
result.stdout.fnmatch_lines("""
177+
result.stdout.re_match_lines(r"""
178178
test_scope_package_a/test_01.py::test_a PASSED
179179
test_scope_package_b/test_02.py::test_c PASSED
180180
test_scope_package_b/test_02.py::test_d FAILED
181181
test_scope_package_b/test_03.py::test_e PASSED
182-
test_scope_package_b/test_03.py::test_f SKIPPED
182+
test_scope_package_b/test_03.py::test_f SKIPPED(?:\s+\(.*\))?
183183
test_scope_package_b/test_03.py::test_g PASSED
184-
test_scope_package_b/test_03.py::test_h SKIPPED
184+
test_scope_package_b/test_03.py::test_h SKIPPED(?:\s+\(.*\))?
185185
""")
186186

187187
def test_scope_class(ctestdir):
@@ -236,17 +236,17 @@ def test_h(self):
236236
""")
237237
result = ctestdir.runpytest("--verbose")
238238
result.assert_outcomes(passed=5, skipped=3, failed=2)
239-
result.stdout.fnmatch_lines("""
239+
result.stdout.re_match_lines(r"""
240240
test_scope_class.py::test_a FAILED
241241
test_scope_class.py::test_b PASSED
242242
test_scope_class.py::TestClass1::test_c PASSED
243243
test_scope_class.py::TestClass2::test_a PASSED
244244
test_scope_class.py::TestClass2::test_b FAILED
245-
test_scope_class.py::TestClass2::test_d SKIPPED
245+
test_scope_class.py::TestClass2::test_d SKIPPED(?:\s+\(.*\))?
246246
test_scope_class.py::TestClass2::test_e PASSED
247247
test_scope_class.py::TestClass2::test_f PASSED
248-
test_scope_class.py::TestClass2::test_g SKIPPED
249-
test_scope_class.py::TestClass2::test_h SKIPPED
248+
test_scope_class.py::TestClass2::test_g SKIPPED(?:\s+\(.*\))?
249+
test_scope_class.py::TestClass2::test_h SKIPPED(?:\s+\(.*\))?
250250
""")
251251

252252
def test_scope_nodeid(ctestdir):
@@ -360,21 +360,21 @@ def test_o(self):
360360
""")
361361
result = ctestdir.runpytest("--verbose")
362362
result.assert_outcomes(passed=7, skipped=8, failed=0)
363-
result.stdout.fnmatch_lines("""
363+
result.stdout.re_match_lines(r"""
364364
test_scope_nodeid.py::test_a PASSED
365365
test_scope_nodeid.py::test_b PASSED
366-
test_scope_nodeid.py::test_c SKIPPED
367-
test_scope_nodeid.py::test_d SKIPPED
366+
test_scope_nodeid.py::test_c SKIPPED(?:\s+\(.*\))?
367+
test_scope_nodeid.py::test_d SKIPPED(?:\s+\(.*\))?
368368
test_scope_nodeid.py::test_e PASSED
369369
test_scope_nodeid.py::TestClass::test_f PASSED
370370
test_scope_nodeid.py::TestClass::test_g PASSED
371-
test_scope_nodeid.py::TestClass::test_h SKIPPED
372-
test_scope_nodeid.py::TestClass::test_i SKIPPED
373-
test_scope_nodeid.py::TestClass::test_j SKIPPED
371+
test_scope_nodeid.py::TestClass::test_h SKIPPED(?:\s+\(.*\))?
372+
test_scope_nodeid.py::TestClass::test_i SKIPPED(?:\s+\(.*\))?
373+
test_scope_nodeid.py::TestClass::test_j SKIPPED(?:\s+\(.*\))?
374374
test_scope_nodeid.py::TestClass::test_k PASSED
375-
test_scope_nodeid.py::TestClass::test_l SKIPPED
376-
test_scope_nodeid.py::TestClass::test_m SKIPPED
377-
test_scope_nodeid.py::TestClass::test_n SKIPPED
375+
test_scope_nodeid.py::TestClass::test_l SKIPPED(?:\s+\(.*\))?
376+
test_scope_nodeid.py::TestClass::test_m SKIPPED(?:\s+\(.*\))?
377+
test_scope_nodeid.py::TestClass::test_n SKIPPED(?:\s+\(.*\))?
378378
test_scope_nodeid.py::TestClass::test_o PASSED
379379
""")
380380

@@ -467,19 +467,19 @@ def test_l(self):
467467
""")
468468
result = ctestdir.runpytest("--verbose")
469469
result.assert_outcomes(passed=7, skipped=5, failed=0)
470-
result.stdout.fnmatch_lines("""
470+
result.stdout.re_match_lines(r"""
471471
test_scope_named.py::test_a PASSED
472472
test_scope_named.py::test_b PASSED
473-
test_scope_named.py::test_c SKIPPED
473+
test_scope_named.py::test_c SKIPPED(?:\s+\(.*\))?
474474
test_scope_named.py::test_d PASSED
475-
test_scope_named.py::test_e SKIPPED
475+
test_scope_named.py::test_e SKIPPED(?:\s+\(.*\))?
476476
test_scope_named.py::TestClass::test_f PASSED
477477
test_scope_named.py::TestClass::test_g PASSED
478-
test_scope_named.py::TestClass::test_h SKIPPED
478+
test_scope_named.py::TestClass::test_h SKIPPED(?:\s+\(.*\))?
479479
test_scope_named.py::TestClass::test_i PASSED
480-
test_scope_named.py::TestClass::test_j SKIPPED
480+
test_scope_named.py::TestClass::test_j SKIPPED(?:\s+\(.*\))?
481481
test_scope_named.py::TestClass::test_k PASSED
482-
test_scope_named.py::TestClass::test_l SKIPPED
482+
test_scope_named.py::TestClass::test_l SKIPPED(?:\s+\(.*\))?
483483
""")
484484

485485
def test_scope_dependsfunc(ctestdir):
@@ -578,21 +578,21 @@ def test_d(self, request):
578578
""")
579579
result = ctestdir.runpytest("--verbose")
580580
result.assert_outcomes(passed=10, skipped=3, failed=3)
581-
result.stdout.fnmatch_lines("""
581+
result.stdout.re_match_lines(r"""
582582
test_scope_dependsfunc_01.py::test_a PASSED
583583
test_scope_dependsfunc_01.py::test_b FAILED
584584
test_scope_dependsfunc_01.py::test_c PASSED
585585
test_scope_dependsfunc_01.py::TestClass::test_b PASSED
586586
test_scope_dependsfunc_02.py::test_a FAILED
587587
test_scope_dependsfunc_02.py::test_b PASSED
588588
test_scope_dependsfunc_02.py::test_e PASSED
589-
test_scope_dependsfunc_02.py::test_f SKIPPED
589+
test_scope_dependsfunc_02.py::test_f SKIPPED(?:\s+\(.*\))?
590590
test_scope_dependsfunc_02.py::test_g PASSED
591591
test_scope_dependsfunc_02.py::test_h PASSED
592-
test_scope_dependsfunc_02.py::test_i SKIPPED
592+
test_scope_dependsfunc_02.py::test_i SKIPPED(?:\s+\(.*\))?
593593
test_scope_dependsfunc_02.py::test_j PASSED
594594
test_scope_dependsfunc_02.py::TestClass::test_a PASSED
595595
test_scope_dependsfunc_02.py::TestClass::test_b FAILED
596596
test_scope_dependsfunc_02.py::TestClass::test_c PASSED
597-
test_scope_dependsfunc_02.py::TestClass::test_d SKIPPED
597+
test_scope_dependsfunc_02.py::TestClass::test_d SKIPPED(?:\s+\(.*\))?
598598
""")

tests/test_03_skipmsgs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ def test_d():
2929
""")
3030
result = ctestdir.runpytest("--verbose", "-rs")
3131
result.assert_outcomes(passed=1, skipped=2, failed=1)
32-
result.stdout.fnmatch_lines("""
33-
*::test_a PASSED
34-
*::test_b FAILED
35-
*::test_c SKIPPED
36-
*::test_d SKIPPED
32+
result.stdout.re_match_lines(r"""
33+
.*::test_a PASSED
34+
.*::test_b FAILED
35+
.*::test_c SKIPPED(?:\s+\(.*\))?
36+
.*::test_d SKIPPED(?:\s+\(.*\))?
3737
""")
3838
result.stdout.fnmatch_lines_random("""
3939
SKIP* test_c depends on test_b

0 commit comments

Comments
 (0)