Skip to content

Commit 87fecce

Browse files
authored
Merge pull request #6600 from blueyed/harden-test_teardown_many_verbose
tests: harden test_teardown_many_verbose
2 parents 05d953d + b01e379 commit 87fecce

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

testing/test_terminal.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
}
3434
RE_COLORS = {k: re.escape(v) for k, v in COLORS.items()}
3535

36+
TRANS_FNMATCH = str.maketrans({"[": "[[]", "]": "[]]"})
37+
3638

3739
class Option:
3840
def __init__(self, verbosity=0):
@@ -1772,14 +1774,19 @@ def test_teardown_many(self, testdir, many_files):
17721774
[r"test_bar.py (\.E){5}\s+\[ 25%\]", r"test_foo.py (\.E){15}\s+\[100%\]"]
17731775
)
17741776

1775-
def test_teardown_many_verbose(self, testdir, many_files):
1776-
output = testdir.runpytest("-v")
1777-
output.stdout.re_match_lines(
1777+
def test_teardown_many_verbose(self, testdir: Testdir, many_files) -> None:
1778+
result = testdir.runpytest("-v")
1779+
result.stdout.fnmatch_lines(
17781780
[
1779-
r"test_bar.py::test_bar\[0\] PASSED\s+\[ 5%\]",
1780-
r"test_bar.py::test_bar\[0\] ERROR\s+\[ 5%\]",
1781-
r"test_bar.py::test_bar\[4\] PASSED\s+\[ 25%\]",
1782-
r"test_bar.py::test_bar\[4\] ERROR\s+\[ 25%\]",
1781+
line.translate(TRANS_FNMATCH)
1782+
for line in [
1783+
"test_bar.py::test_bar[0] PASSED * [ 5%]",
1784+
"test_bar.py::test_bar[0] ERROR * [ 5%]",
1785+
"test_bar.py::test_bar[4] PASSED * [ 25%]",
1786+
"test_foo.py::test_foo[14] PASSED * [100%]",
1787+
"test_foo.py::test_foo[14] ERROR * [100%]",
1788+
"=* 20 passed, 20 errors in *",
1789+
]
17831790
]
17841791
)
17851792

0 commit comments

Comments
 (0)