jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/692716 )

Change subject: [bugfix] Flush stream in TerminalHandler.emit()
......................................................................

[bugfix] Flush stream in TerminalHandler.emit()

Bug: T282962
Change-Id: Ia3730d0a7354e6affb3b5a016e903887db46f3c9
---
M pywikibot/userinterfaces/terminal_interface_base.py
M tests/ui_tests.py
2 files changed, 4 insertions(+), 19 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/userinterfaces/terminal_interface_base.py 
b/pywikibot/userinterfaces/terminal_interface_base.py
index c4abe8b..642fd83 100755
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -523,6 +523,7 @@

     def emit(self, record):
         """Emit the record formatted to the output."""
+        self.flush()
         if record.name == 'py.warnings':
             # Each warning appears twice
             # the second time it has a 'message'
diff --git a/tests/ui_tests.py b/tests/ui_tests.py
index f76c258..f9c76c9 100644
--- a/tests/ui_tests.py
+++ b/tests/ui_tests.py
@@ -8,6 +8,8 @@
 import logging
 import os
 import sys
+import unittest
+
 from contextlib import suppress

 import pywikibot
@@ -28,10 +30,7 @@
     terminal_interface_win32,
 )
 from tests.aspects import TestCase, TestCaseBase
-from tests.utils import expected_failure_if, FakeModule, unittest
-
-
-TRAVIS = os.getenv('TRAVIS', 'false') == 'true'
+from tests.utils import FakeModule


 class Stream:
@@ -146,7 +145,6 @@
         ('CRITICAL', CRITICAL, '', 'CRITICAL: CRITICAL\n'),
     ]

-    @expected_failure_if(TRAVIS)
     def test_outputlevels_logging(self):
         """Test logger with output levels."""
         for text, level, out, err in self.tests:
@@ -156,7 +154,6 @@
                 self.assertEqual(newstderr.getvalue(), err)
                 patch()  # reset terminal files

-    @expected_failure_if(TRAVIS)
     def test_output(self):
         pywikibot.output('output')
         self.assertEqual(newstdout.getvalue(), '')
@@ -167,13 +164,11 @@
         self.assertEqual(newstdout.getvalue(), 'output\n')
         self.assertEqual(newstderr.getvalue(), '')

-    @expected_failure_if(TRAVIS)
     def test_warning(self):
         pywikibot.warning('warning')
         self.assertEqual(newstdout.getvalue(), '')
         self.assertEqual(newstderr.getvalue(), 'WARNING: warning\n')

-    @expected_failure_if(TRAVIS)
     def test_error(self):
         pywikibot.error('error')
         self.assertEqual(newstdout.getvalue(), '')
@@ -184,7 +179,6 @@
         self.assertEqual(newstdout.getvalue(), '')
         self.assertEqual(newstderr.getvalue(), '')

-    @expected_failure_if(TRAVIS)
     def test_critical(self):
         pywikibot.critical('critical')
         self.assertEqual(newstdout.getvalue(), '')
@@ -195,7 +189,6 @@
         self.assertEqual(newstdout.getvalue(), '')
         self.assertEqual(newstderr.getvalue(), '')

-    @expected_failure_if(TRAVIS)
     def test_exception(self):
         class TestException(Exception):

@@ -209,7 +202,6 @@
         self.assertEqual(newstderr.getvalue(),
                          'ERROR: TestException: Testing Exception\n')

-    @expected_failure_if(TRAVIS)
     def test_exception_tb(self):
         class TestException(Exception):

@@ -237,7 +229,6 @@

     input_choice_output = 'question ([A]nswer 1, a[n]swer 2, an[s]wer 3): '

-    @expected_failure_if(TRAVIS)
     def testInput(self):
         newstdin.write('input to read\n')
         newstdin.seek(0)
@@ -248,7 +239,6 @@
         self.assertIsInstance(returned, str)
         self.assertEqual(returned, 'input to read')

-    @expected_failure_if(TRAVIS)
     def test_input_yn(self):
         newstdin.write('\n')
         newstdin.seek(0)
@@ -278,7 +268,6 @@

         self.assertEqual(returned, 'a')

-    @expected_failure_if(TRAVIS)
     def testInputChoiceCapital(self):
         newstdin.write('N\n')
         newstdin.seek(0)
@@ -287,7 +276,6 @@
         self.assertEqual(newstderr.getvalue(), self.input_choice_output)
         self.assertEqual(returned, 'n')

-    @expected_failure_if(TRAVIS)
     def testInputChoiceNonCapital(self):
         newstdin.write('n\n')
         newstdin.seek(0)
@@ -296,7 +284,6 @@
         self.assertEqual(newstderr.getvalue(), self.input_choice_output)
         self.assertEqual(returned, 'n')

-    @expected_failure_if(TRAVIS)
     def testInputChoiceIncorrectAnswer(self):
         newstdin.write('X\nN\n')
         newstdin.seek(0)
@@ -307,7 +294,6 @@


 @unittest.skipUnless(os.name == 'posix', 'requires Unix console')
-@expected_failure_if(TRAVIS)
 class TestTerminalOutputColorUnix(UITestCase):

     """Terminal output color tests."""
@@ -345,7 +331,6 @@


 @unittest.skipUnless(os.name == 'posix', 'requires Unix console')
-@expected_failure_if(TRAVIS)
 class TestTerminalUnicodeUnix(UITestCase):

     """Terminal output tests for unix."""
@@ -370,7 +355,6 @@


 @unittest.skipUnless(os.name == 'posix', 'requires Unix console')
-@expected_failure_if(TRAVIS)
 class TestTransliterationUnix(UITestCase):

     """Terminal output transliteration tests."""

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/692716
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ia3730d0a7354e6affb3b5a016e903887db46f3c9
Gerrit-Change-Number: 692716
Gerrit-PatchSet: 18
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to