jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/355639 )
Change subject: Correctly test warning in TestTerminalOutput.test_output_stdout ......................................................................
Correctly test warning in TestTerminalOutput.test_output_stdout
Instead of testing for a given output, check that the correct warning is triggered in the warning library.
Change-Id: Ibb83ac2504547e9feef241a7ceb159d8b4f84311 --- M tests/ui_tests.py 1 file changed, 10 insertions(+), 5 deletions(-)
Approvals: Multichill: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/ui_tests.py b/tests/ui_tests.py index 75fd646..228249e 100644 --- a/tests/ui_tests.py +++ b/tests/ui_tests.py @@ -33,6 +33,7 @@ import subprocess import sys import time +import warnings
if os.name == "nt": from multiprocessing.managers import BaseManager @@ -285,11 +286,15 @@ self.assertEqual(newstderr.getvalue(), 'output\n')
def test_output_stdout(self): - pywikibot.output('output', toStdout=True) - self.assertEqual(newstdout.getvalue(), 'output\n') - self.assertIn('DeprecationWarning: "toStdout" parameter is ' - 'deprecated; use pywikibot.stdout() instead.\n', - newstderr.getvalue(),) + with warnings.catch_warnings(record=True) as w: + pywikibot.output('output', toStdout=True) + self.assertEqual(newstdout.getvalue(), 'output\n') + self.assertEqual(len(w), 1) + self.assertEqual(w[0].category, DeprecationWarning) + self.assertEqual( + str(w[0].message), + '"toStdout" parameter is deprecated; use pywikibot.stdout() instead.' + )
def test_stdout(self): pywikibot.stdout('output')
pywikibot-commits@lists.wikimedia.org