Skip to content

Commit cee35bb

Browse files
committed
Simplify test assertions a bit
1 parent de42d42 commit cee35bb

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

testing/logging/test_reporting.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,7 @@ def test_log_cli(request):
217217
'test_log_cli_level.py*This log message will be shown',
218218
'PASSED', # 'PASSED' on its own line because the log message prints a new line
219219
])
220-
for line in result.outlines:
221-
try:
222-
assert "This log message won't be shown" in line
223-
pytest.fail("A log message was shown and it shouldn't have been")
224-
except AssertionError:
225-
continue
220+
assert "This log message won't be shown" not in result.stdout.str()
226221

227222
# make sure that that we get a '0' exit code for the testsuite
228223
assert result.ret == 0
@@ -234,12 +229,7 @@ def test_log_cli(request):
234229
'test_log_cli_level.py* This log message will be shown',
235230
'PASSED', # 'PASSED' on its own line because the log message prints a new line
236231
])
237-
for line in result.outlines:
238-
try:
239-
assert "This log message won't be shown" in line
240-
pytest.fail("A log message was shown and it shouldn't have been")
241-
except AssertionError:
242-
continue
232+
assert "This log message won't be shown" not in result.stdout.str()
243233

244234
# make sure that that we get a '0' exit code for the testsuite
245235
assert result.ret == 0
@@ -270,12 +260,7 @@ def test_log_cli(request):
270260
'test_log_cli_ini_level.py* This log message will be shown',
271261
'PASSED', # 'PASSED' on its own line because the log message prints a new line
272262
])
273-
for line in result.outlines:
274-
try:
275-
assert "This log message won't be shown" in line
276-
pytest.fail("A log message was shown and it shouldn't have been")
277-
except AssertionError:
278-
continue
263+
assert "This log message won't be shown" not in result.stdout.str()
279264

280265
# make sure that that we get a '0' exit code for the testsuite
281266
assert result.ret == 0

0 commit comments

Comments
 (0)