From 0930889a13e2b9baa7617f05dc9b55abede5209d Mon Sep 17 00:00:00 2001 From: Rolf Krahl Date: Sun, 21 Feb 2021 13:06:35 +0100 Subject: [PATCH] Adapt matching of expected output in the tests to adapt to changes in pytest 6.2.0 and newer, fix #50 --- tests/test_02_simple_dependency.py | 54 ++++++++++++------------ tests/test_03_class.py | 32 +++++++------- tests/test_03_multiple_dependency.py | 24 +++++------ tests/test_03_param.py | 28 ++++++------- tests/test_03_runtime.py | 10 ++--- tests/test_03_scope.py | 62 ++++++++++++++-------------- tests/test_03_skipmsgs.py | 10 ++--- tests/test_04_automark.py | 18 ++++---- tests/test_04_ignore_unknown.py | 8 ++-- 9 files changed, 123 insertions(+), 123 deletions(-) diff --git a/tests/test_02_simple_dependency.py b/tests/test_02_simple_dependency.py index a010f80..3c45f2c 100644 --- a/tests/test_02_simple_dependency.py +++ b/tests/test_02_simple_dependency.py @@ -29,11 +29,11 @@ def test_d(): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=3, skipped=1, failed=0) - result.stdout.fnmatch_lines(""" - *::test_a SKIPPED - *::test_b PASSED - *::test_c PASSED - *::test_d PASSED + result.stdout.re_match_lines(r""" + .*::test_a SKIPPED(?:\s+\(.*\))? + .*::test_b PASSED + .*::test_c PASSED + .*::test_d PASSED """) @@ -62,11 +62,11 @@ def test_d(): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=1, skipped=3, failed=0) - result.stdout.fnmatch_lines(""" - *::test_a PASSED - *::test_b SKIPPED - *::test_c SKIPPED - *::test_d SKIPPED + result.stdout.re_match_lines(r""" + .*::test_a PASSED + .*::test_b SKIPPED(?:\s+\(.*\))? + .*::test_c SKIPPED(?:\s+\(.*\))? + .*::test_d SKIPPED(?:\s+\(.*\))? """) @@ -95,11 +95,11 @@ def test_d(): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=1, skipped=2, failed=1) - result.stdout.fnmatch_lines(""" - *::test_a PASSED - *::test_b FAILED - *::test_c SKIPPED - *::test_d SKIPPED + result.stdout.re_match_lines(r""" + .*::test_a PASSED + .*::test_b FAILED + .*::test_c SKIPPED(?:\s+\(.*\))? + .*::test_d SKIPPED(?:\s+\(.*\))? """) @@ -127,11 +127,11 @@ def test_d(): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=1, skipped=2, failed=1) - result.stdout.fnmatch_lines(""" - *::test_a PASSED - *::test_b FAILED - *::test_c SKIPPED - *::test_d SKIPPED + result.stdout.re_match_lines(r""" + .*::test_a PASSED + .*::test_b FAILED + .*::test_c SKIPPED(?:\s+\(.*\))? + .*::test_d SKIPPED(?:\s+\(.*\))? """) @@ -162,8 +162,8 @@ def test_d(): """) result = ctestdir.runpytest("--verbose", "test_explicit_select.py::test_d") result.assert_outcomes(passed=0, skipped=1, failed=0) - result.stdout.fnmatch_lines(""" - *::test_d SKIPPED + result.stdout.re_match_lines(r""" + .*::test_d SKIPPED(?:\s+\(.*\))? """) @@ -195,9 +195,9 @@ def test_d(): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=3, skipped=1, failed=0) - result.stdout.fnmatch_lines(""" - *::test_a PASSED - *::test_b PASSED - *::test_c PASSED - *::test_d SKIPPED + result.stdout.re_match_lines(r""" + .*::test_a PASSED + .*::test_b PASSED + .*::test_c PASSED + .*::test_d SKIPPED(?:\s+\(.*\))? """) diff --git a/tests/test_03_class.py b/tests/test_03_class.py index 2ebf811..168b634 100644 --- a/tests/test_03_class.py +++ b/tests/test_03_class.py @@ -36,12 +36,12 @@ def test_e(self): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=2, skipped=2, failed=1) - result.stdout.fnmatch_lines(""" - *::TestClass::test_a FAILED - *::TestClass::test_b PASSED - *::TestClass::test_c SKIPPED - *::TestClass::test_d PASSED - *::TestClass::test_e SKIPPED + result.stdout.re_match_lines(r""" + .*::TestClass::test_a FAILED + .*::TestClass::test_b PASSED + .*::TestClass::test_c SKIPPED(?:\s+\(.*\))? + .*::TestClass::test_d PASSED + .*::TestClass::test_e SKIPPED(?:\s+\(.*\))? """) @@ -76,12 +76,12 @@ def test_e(self): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=2, skipped=2, failed=1) - result.stdout.fnmatch_lines(""" - *::TestClassNamed::test_a FAILED - *::TestClassNamed::test_b PASSED - *::TestClassNamed::test_c SKIPPED - *::TestClassNamed::test_d PASSED - *::TestClassNamed::test_e SKIPPED + result.stdout.re_match_lines(r""" + .*::TestClassNamed::test_a FAILED + .*::TestClassNamed::test_b PASSED + .*::TestClassNamed::test_c SKIPPED(?:\s+\(.*\))? + .*::TestClassNamed::test_d PASSED + .*::TestClassNamed::test_e SKIPPED(?:\s+\(.*\))? """) @@ -114,8 +114,8 @@ def test_b(): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=1, skipped=1, failed=1) - result.stdout.fnmatch_lines(""" - *::test_a FAILED - *::TestClass::test_a PASSED - *::test_b SKIPPED + result.stdout.re_match_lines(r""" + .*::test_a FAILED + .*::TestClass::test_a PASSED + .*::test_b SKIPPED(?:\s+\(.*\))? """) diff --git a/tests/test_03_multiple_dependency.py b/tests/test_03_multiple_dependency.py index aaea86b..a5e585a 100644 --- a/tests/test_03_multiple_dependency.py +++ b/tests/test_03_multiple_dependency.py @@ -54,16 +54,16 @@ def test_k(): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=5, skipped=5, failed=1) - result.stdout.fnmatch_lines(""" - *::test_a SKIPPED - *::test_b FAILED - *::test_c PASSED - *::test_d PASSED - *::test_e PASSED - *::test_f SKIPPED - *::test_g SKIPPED - *::test_h PASSED - *::test_i SKIPPED - *::test_j PASSED - *::test_k SKIPPED + result.stdout.re_match_lines(r""" + .*::test_a SKIPPED(?:\s+\(.*\))? + .*::test_b FAILED + .*::test_c PASSED + .*::test_d PASSED + .*::test_e PASSED + .*::test_f SKIPPED(?:\s+\(.*\))? + .*::test_g SKIPPED(?:\s+\(.*\))? + .*::test_h PASSED + .*::test_i SKIPPED(?:\s+\(.*\))? + .*::test_j PASSED + .*::test_k SKIPPED(?:\s+\(.*\))? """) diff --git a/tests/test_03_param.py b/tests/test_03_param.py index 8c0e53d..a7a31b0 100644 --- a/tests/test_03_param.py +++ b/tests/test_03_param.py @@ -40,18 +40,18 @@ def test_c(w): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=7, skipped=5, failed=1) - result.stdout.fnmatch_lines(""" - *::test_a?0-0? PASSED - *::test_a?0-1? PASSED - *::test_a?1-0? PASSED - *::test_a?1-1? FAILED - *::test_b?1-2? PASSED - *::test_b?1-3? PASSED - *::test_b?1-4? SKIPPED - *::test_b?2-3? PASSED - *::test_b?2-4? SKIPPED - *::test_b?3-4? SKIPPED - *::test_c?1? SKIPPED - *::test_c?2? SKIPPED - *::test_c?3? PASSED + result.stdout.re_match_lines(r""" + .*::test_a\[0-0\] PASSED + .*::test_a\[0-1\] PASSED + .*::test_a\[1-0\] PASSED + .*::test_a\[1-1\] FAILED + .*::test_b\[1-2\] PASSED + .*::test_b\[1-3\] PASSED + .*::test_b\[1-4\] SKIPPED(?:\s+\(.*\))? + .*::test_b\[2-3\] PASSED + .*::test_b\[2-4\] SKIPPED(?:\s+\(.*\))? + .*::test_b\[3-4\] SKIPPED(?:\s+\(.*\))? + .*::test_c\[1\] SKIPPED(?:\s+\(.*\))? + .*::test_c\[2\] SKIPPED(?:\s+\(.*\))? + .*::test_c\[3\] PASSED """) diff --git a/tests/test_03_runtime.py b/tests/test_03_runtime.py index fd35b2b..fb23e2c 100644 --- a/tests/test_03_runtime.py +++ b/tests/test_03_runtime.py @@ -32,9 +32,9 @@ def test_d(request): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=1, skipped=3, failed=0) - result.stdout.fnmatch_lines(""" - *::test_a PASSED - *::test_b SKIPPED - *::test_c SKIPPED - *::test_d SKIPPED + result.stdout.re_match_lines(r""" + .*::test_a PASSED + .*::test_b SKIPPED(?:\s+\(.*\))? + .*::test_c SKIPPED(?:\s+\(.*\))? + .*::test_d SKIPPED(?:\s+\(.*\))? """) diff --git a/tests/test_03_scope.py b/tests/test_03_scope.py index ba28377..58aad89 100644 --- a/tests/test_03_scope.py +++ b/tests/test_03_scope.py @@ -33,12 +33,12 @@ def test_e(): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=2, skipped=2, failed=1) - result.stdout.fnmatch_lines(""" + result.stdout.re_match_lines(r""" test_scope_module.py::test_a FAILED test_scope_module.py::test_b PASSED - test_scope_module.py::test_c SKIPPED + test_scope_module.py::test_c SKIPPED(?:\s+\(.*\))? test_scope_module.py::test_d PASSED - test_scope_module.py::test_e SKIPPED + test_scope_module.py::test_e SKIPPED(?:\s+\(.*\))? """) def test_scope_session(ctestdir): @@ -102,14 +102,14 @@ def test_h(): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=6, skipped=1, failed=2) - result.stdout.fnmatch_lines(""" + result.stdout.re_match_lines(r""" test_scope_session_01.py::test_a PASSED test_scope_session_01.py::test_b FAILED test_scope_session_01.py::test_c PASSED test_scope_session_01.py::TestClass::test_b PASSED test_scope_session_02.py::test_a FAILED test_scope_session_02.py::test_e PASSED - test_scope_session_02.py::test_f SKIPPED + test_scope_session_02.py::test_f SKIPPED(?:\s+\(.*\))? test_scope_session_02.py::test_g PASSED test_scope_session_02.py::test_h PASSED """) @@ -174,14 +174,14 @@ def test_h(): ctestdir.makepyfile(**srcs) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=4, skipped=2, failed=1) - result.stdout.fnmatch_lines(""" + result.stdout.re_match_lines(r""" test_scope_package_a/test_01.py::test_a PASSED test_scope_package_b/test_02.py::test_c PASSED test_scope_package_b/test_02.py::test_d FAILED test_scope_package_b/test_03.py::test_e PASSED - test_scope_package_b/test_03.py::test_f SKIPPED + test_scope_package_b/test_03.py::test_f SKIPPED(?:\s+\(.*\))? test_scope_package_b/test_03.py::test_g PASSED - test_scope_package_b/test_03.py::test_h SKIPPED + test_scope_package_b/test_03.py::test_h SKIPPED(?:\s+\(.*\))? """) def test_scope_class(ctestdir): @@ -236,17 +236,17 @@ def test_h(self): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=5, skipped=3, failed=2) - result.stdout.fnmatch_lines(""" + result.stdout.re_match_lines(r""" test_scope_class.py::test_a FAILED test_scope_class.py::test_b PASSED test_scope_class.py::TestClass1::test_c PASSED test_scope_class.py::TestClass2::test_a PASSED test_scope_class.py::TestClass2::test_b FAILED - test_scope_class.py::TestClass2::test_d SKIPPED + test_scope_class.py::TestClass2::test_d SKIPPED(?:\s+\(.*\))? test_scope_class.py::TestClass2::test_e PASSED test_scope_class.py::TestClass2::test_f PASSED - test_scope_class.py::TestClass2::test_g SKIPPED - test_scope_class.py::TestClass2::test_h SKIPPED + test_scope_class.py::TestClass2::test_g SKIPPED(?:\s+\(.*\))? + test_scope_class.py::TestClass2::test_h SKIPPED(?:\s+\(.*\))? """) def test_scope_nodeid(ctestdir): @@ -360,21 +360,21 @@ def test_o(self): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=7, skipped=8, failed=0) - result.stdout.fnmatch_lines(""" + result.stdout.re_match_lines(r""" test_scope_nodeid.py::test_a PASSED test_scope_nodeid.py::test_b PASSED - test_scope_nodeid.py::test_c SKIPPED - test_scope_nodeid.py::test_d SKIPPED + test_scope_nodeid.py::test_c SKIPPED(?:\s+\(.*\))? + test_scope_nodeid.py::test_d SKIPPED(?:\s+\(.*\))? test_scope_nodeid.py::test_e PASSED test_scope_nodeid.py::TestClass::test_f PASSED test_scope_nodeid.py::TestClass::test_g PASSED - test_scope_nodeid.py::TestClass::test_h SKIPPED - test_scope_nodeid.py::TestClass::test_i SKIPPED - test_scope_nodeid.py::TestClass::test_j SKIPPED + test_scope_nodeid.py::TestClass::test_h SKIPPED(?:\s+\(.*\))? + test_scope_nodeid.py::TestClass::test_i SKIPPED(?:\s+\(.*\))? + test_scope_nodeid.py::TestClass::test_j SKIPPED(?:\s+\(.*\))? test_scope_nodeid.py::TestClass::test_k PASSED - test_scope_nodeid.py::TestClass::test_l SKIPPED - test_scope_nodeid.py::TestClass::test_m SKIPPED - test_scope_nodeid.py::TestClass::test_n SKIPPED + test_scope_nodeid.py::TestClass::test_l SKIPPED(?:\s+\(.*\))? + test_scope_nodeid.py::TestClass::test_m SKIPPED(?:\s+\(.*\))? + test_scope_nodeid.py::TestClass::test_n SKIPPED(?:\s+\(.*\))? test_scope_nodeid.py::TestClass::test_o PASSED """) @@ -467,19 +467,19 @@ def test_l(self): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=7, skipped=5, failed=0) - result.stdout.fnmatch_lines(""" + result.stdout.re_match_lines(r""" test_scope_named.py::test_a PASSED test_scope_named.py::test_b PASSED - test_scope_named.py::test_c SKIPPED + test_scope_named.py::test_c SKIPPED(?:\s+\(.*\))? test_scope_named.py::test_d PASSED - test_scope_named.py::test_e SKIPPED + test_scope_named.py::test_e SKIPPED(?:\s+\(.*\))? test_scope_named.py::TestClass::test_f PASSED test_scope_named.py::TestClass::test_g PASSED - test_scope_named.py::TestClass::test_h SKIPPED + test_scope_named.py::TestClass::test_h SKIPPED(?:\s+\(.*\))? test_scope_named.py::TestClass::test_i PASSED - test_scope_named.py::TestClass::test_j SKIPPED + test_scope_named.py::TestClass::test_j SKIPPED(?:\s+\(.*\))? test_scope_named.py::TestClass::test_k PASSED - test_scope_named.py::TestClass::test_l SKIPPED + test_scope_named.py::TestClass::test_l SKIPPED(?:\s+\(.*\))? """) def test_scope_dependsfunc(ctestdir): @@ -578,7 +578,7 @@ def test_d(self, request): """) result = ctestdir.runpytest("--verbose") result.assert_outcomes(passed=10, skipped=3, failed=3) - result.stdout.fnmatch_lines(""" + result.stdout.re_match_lines(r""" test_scope_dependsfunc_01.py::test_a PASSED test_scope_dependsfunc_01.py::test_b FAILED test_scope_dependsfunc_01.py::test_c PASSED @@ -586,13 +586,13 @@ def test_d(self, request): test_scope_dependsfunc_02.py::test_a FAILED test_scope_dependsfunc_02.py::test_b PASSED test_scope_dependsfunc_02.py::test_e PASSED - test_scope_dependsfunc_02.py::test_f SKIPPED + test_scope_dependsfunc_02.py::test_f SKIPPED(?:\s+\(.*\))? test_scope_dependsfunc_02.py::test_g PASSED test_scope_dependsfunc_02.py::test_h PASSED - test_scope_dependsfunc_02.py::test_i SKIPPED + test_scope_dependsfunc_02.py::test_i SKIPPED(?:\s+\(.*\))? test_scope_dependsfunc_02.py::test_j PASSED test_scope_dependsfunc_02.py::TestClass::test_a PASSED test_scope_dependsfunc_02.py::TestClass::test_b FAILED test_scope_dependsfunc_02.py::TestClass::test_c PASSED - test_scope_dependsfunc_02.py::TestClass::test_d SKIPPED + test_scope_dependsfunc_02.py::TestClass::test_d SKIPPED(?:\s+\(.*\))? """) diff --git a/tests/test_03_skipmsgs.py b/tests/test_03_skipmsgs.py index d501285..bfdc833 100644 --- a/tests/test_03_skipmsgs.py +++ b/tests/test_03_skipmsgs.py @@ -29,11 +29,11 @@ def test_d(): """) result = ctestdir.runpytest("--verbose", "-rs") result.assert_outcomes(passed=1, skipped=2, failed=1) - result.stdout.fnmatch_lines(""" - *::test_a PASSED - *::test_b FAILED - *::test_c SKIPPED - *::test_d SKIPPED + result.stdout.re_match_lines(r""" + .*::test_a PASSED + .*::test_b FAILED + .*::test_c SKIPPED(?:\s+\(.*\))? + .*::test_d SKIPPED(?:\s+\(.*\))? """) result.stdout.fnmatch_lines_random(""" SKIP* test_c depends on test_b diff --git a/tests/test_04_automark.py b/tests/test_04_automark.py index bcc2810..7251405 100644 --- a/tests/test_04_automark.py +++ b/tests/test_04_automark.py @@ -23,9 +23,9 @@ def test_b(): """) result = ctestdir.runpytest("--verbose", "-rs") result.assert_outcomes(passed=1, skipped=1, failed=0) - result.stdout.fnmatch_lines(""" - *::test_a PASSED - *::test_b SKIPPED + result.stdout.re_match_lines(r""" + .*::test_a PASSED + .*::test_b SKIPPED(?:\s+\(.*\))? """) @@ -53,9 +53,9 @@ def test_b(): """) result = ctestdir.runpytest("--verbose", "-rs") result.assert_outcomes(passed=1, skipped=1, failed=0) - result.stdout.fnmatch_lines(""" - *::test_a PASSED - *::test_b SKIPPED + result.stdout.re_match_lines(r""" + .*::test_a PASSED + .*::test_b SKIPPED(?:\s+\(.*\))? """) @@ -83,7 +83,7 @@ def test_b(): """) result = ctestdir.runpytest("--verbose", "-rs") result.assert_outcomes(passed=2, skipped=0, failed=0) - result.stdout.fnmatch_lines(""" - *::test_a PASSED - *::test_b PASSED + result.stdout.re_match_lines(r""" + .*::test_a PASSED + .*::test_b PASSED """) diff --git a/tests/test_04_ignore_unknown.py b/tests/test_04_ignore_unknown.py index 3cee600..bc145e5 100644 --- a/tests/test_04_ignore_unknown.py +++ b/tests/test_04_ignore_unknown.py @@ -32,8 +32,8 @@ def test_d(): """) result = ctestdir.runpytest("--verbose", "test_no_ignore.py::test_d") result.assert_outcomes(passed=0, skipped=1, failed=0) - result.stdout.fnmatch_lines(""" - *::test_d SKIPPED + result.stdout.re_match_lines(r""" + .*::test_d SKIPPED(?:\s+\(.*\))? """) @@ -67,6 +67,6 @@ def test_d(): result = ctestdir.runpytest("--verbose", "--ignore-unknown-dependency", "test_ignore.py::test_d") result.assert_outcomes(passed=1, skipped=0, failed=0) - result.stdout.fnmatch_lines(""" - *::test_d PASSED + result.stdout.re_match_lines(r""" + .*::test_d PASSED """)