From 4a436572a85c9f13fba9f242f87b456f54349a32 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 17 Jan 2018 18:41:20 -0200 Subject: [PATCH] Simplify test assertions a bit --- testing/logging/test_reporting.py | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/testing/logging/test_reporting.py b/testing/logging/test_reporting.py index 9bfda325a..c34d5f7dc 100644 --- a/testing/logging/test_reporting.py +++ b/testing/logging/test_reporting.py @@ -217,12 +217,7 @@ def test_log_cli_level(testdir): 'test_log_cli_level.py*This log message will be shown', 'PASSED', # 'PASSED' on its own line because the log message prints a new line ]) - for line in result.outlines: - try: - assert "This log message won't be shown" in line - pytest.fail("A log message was shown and it shouldn't have been") - except AssertionError: - continue + assert "This log message won't be shown" not in result.stdout.str() # make sure that that we get a '0' exit code for the testsuite assert result.ret == 0 @@ -234,12 +229,7 @@ def test_log_cli_level(testdir): 'test_log_cli_level.py* This log message will be shown', 'PASSED', # 'PASSED' on its own line because the log message prints a new line ]) - for line in result.outlines: - try: - assert "This log message won't be shown" in line - pytest.fail("A log message was shown and it shouldn't have been") - except AssertionError: - continue + assert "This log message won't be shown" not in result.stdout.str() # make sure that that we get a '0' exit code for the testsuite assert result.ret == 0 @@ -270,12 +260,7 @@ def test_log_cli_ini_level(testdir): 'test_log_cli_ini_level.py* This log message will be shown', 'PASSED', # 'PASSED' on its own line because the log message prints a new line ]) - for line in result.outlines: - try: - assert "This log message won't be shown" in line - pytest.fail("A log message was shown and it shouldn't have been") - except AssertionError: - continue + assert "This log message won't be shown" not in result.stdout.str() # make sure that that we get a '0' exit code for the testsuite assert result.ret == 0