Awight has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/345260 )
Change subject: Nicer log capture ...................................................................... Nicer log capture Change-Id: I9e7d92a75823e3bff80a53694d712ab48fb63a8f --- M tests/test_job_wrapper.py 1 file changed, 18 insertions(+), 18 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/process-control refs/changes/60/345260/1 diff --git a/tests/test_job_wrapper.py b/tests/test_job_wrapper.py index 3be5448..8f312eb 100644 --- a/tests/test_job_wrapper.py +++ b/tests/test_job_wrapper.py @@ -29,12 +29,12 @@ @mock.patch("smtplib.SMTP") -def test_return_code(MockSmtp): - with testfixtures.LogCapture() as caplog: - run_job("return_code") +@testfixtures.log_capture() +def test_return_code(MockSmtp, caplog): + run_job("return_code") - loglines = caplog.actual() - assert ("root", "ERROR", "Job False job failed with code 1") in loglines + loglines = caplog.actual() + assert ("root", "ERROR", "Job False job failed with code 1") in loglines MockSmtp().sendmail.assert_called_once() @@ -42,26 +42,26 @@ # Must finish in less than two seconds, i.e. must have timed out. @nose.tools.timed(2) @mock.patch("smtplib.SMTP") -def test_timeout(MockSmtp): - with testfixtures.LogCapture() as caplog: - run_job("timeout") +@testfixtures.log_capture() +def test_timeout(MockSmtp, caplog): + run_job("timeout") - loglines = caplog.actual() - assert ("root", "ERROR", "Job Timing out job timed out after 0.1 seconds") in loglines - assert ("root", "ERROR", "Job Timing out job failed with code -9") in loglines + loglines = caplog.actual() + assert ("root", "ERROR", "Job Timing out job timed out after 0.1 seconds") in loglines + assert ("root", "ERROR", "Job Timing out job failed with code -9") in loglines MockSmtp().sendmail.assert_called_once() @mock.patch("smtplib.SMTP") -def test_stderr(MockSmtp): - with testfixtures.LogCapture() as caplog: - run_job("errors") +@testfixtures.log_capture() +def test_stderr(MockSmtp, caplog): + run_job("errors") - loglines = list(caplog.actual()) - assert ("root", "ERROR", "Job Bad grep job printed things to stderr:") in loglines - assert ("root", "ERROR", "grep: Invalid regular expression\n") in loglines - assert ("root", "ERROR", "Job Bad grep job failed with code 2") in loglines + loglines = list(caplog.actual()) + assert ("root", "ERROR", "Job Bad grep job printed things to stderr:") in loglines + assert ("root", "ERROR", "grep: Invalid regular expression\n") in loglines + assert ("root", "ERROR", "Job Bad grep job failed with code 2") in loglines MockSmtp().sendmail.assert_called_once() -- To view, visit https://gerrit.wikimedia.org/r/345260 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9e7d92a75823e3bff80a53694d712ab48fb63a8f Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/process-control Gerrit-Branch: master Gerrit-Owner: Awight <awi...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits