From b01e3794281468ff9f80f7e445d525d675e70dab Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 28 Jan 2020 15:52:46 +0100 Subject: [PATCH] tests: harden test_teardown_many_verbose --- testing/test_terminal.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/testing/test_terminal.py b/testing/test_terminal.py index f284ad577..c3a0c17e1 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -33,6 +33,8 @@ COLORS = { } RE_COLORS = {k: re.escape(v) for k, v in COLORS.items()} +TRANS_FNMATCH = str.maketrans({"[": "[[]", "]": "[]]"}) + class Option: def __init__(self, verbosity=0): @@ -1772,14 +1774,19 @@ class TestProgressWithTeardown: [r"test_bar.py (\.E){5}\s+\[ 25%\]", r"test_foo.py (\.E){15}\s+\[100%\]"] ) - def test_teardown_many_verbose(self, testdir, many_files): - output = testdir.runpytest("-v") - output.stdout.re_match_lines( + def test_teardown_many_verbose(self, testdir: Testdir, many_files) -> None: + result = testdir.runpytest("-v") + result.stdout.fnmatch_lines( [ - r"test_bar.py::test_bar\[0\] PASSED\s+\[ 5%\]", - r"test_bar.py::test_bar\[0\] ERROR\s+\[ 5%\]", - r"test_bar.py::test_bar\[4\] PASSED\s+\[ 25%\]", - r"test_bar.py::test_bar\[4\] ERROR\s+\[ 25%\]", + line.translate(TRANS_FNMATCH) + for line in [ + "test_bar.py::test_bar[0] PASSED * [ 5%]", + "test_bar.py::test_bar[0] ERROR * [ 5%]", + "test_bar.py::test_bar[4] PASSED * [ 25%]", + "test_foo.py::test_foo[14] PASSED * [100%]", + "test_foo.py::test_foo[14] ERROR * [100%]", + "=* 20 passed, 20 errors in *", + ] ] )