]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-107237: Fix test_udp_reconnection() of test_logging (#107238) (#107245)
authorVictor Stinner <vstinner@python.org>
Tue, 25 Jul 2023 14:49:32 +0000 (16:49 +0200)
committerGitHub <noreply@github.com>
Tue, 25 Jul 2023 14:49:32 +0000 (14:49 +0000)
gh-107237: Fix test_udp_reconnection() of test_logging (#107238)

test_logging: Fix test_udp_reconnection() by increasing the timeout
from 100 ms to 5 minutes (LONG_TIMEOUT).

Replace also blocking wait() with wait(LONG_TIMEOUT) in
test_output() to prevent the test to hang.

(cherry picked from commit ed082383272c2c238e364e9cc83229234aee23cc)

Lib/test/test_logging.py
Misc/NEWS.d/next/Tests/2023-07-25-14-36-33.gh-issue-107237.y1pY79.rst [new file with mode: 0644]

index 76bd8724e29b41618ed17a8ab695dd1ec360f74b..f1f2b75fef869b6d8ecce923afd2a19c26c97327 100644 (file)
@@ -1981,17 +1981,17 @@ class SysLogHandlerTest(BaseTest):
         # The log message sent to the SysLogHandler is properly received.
         logger = logging.getLogger("slh")
         logger.error("sp\xe4m")
-        self.handled.wait()
+        self.handled.wait(support.LONG_TIMEOUT)
         self.assertEqual(self.log_output, b'<11>sp\xc3\xa4m\x00')
         self.handled.clear()
         self.sl_hdlr.append_nul = False
         logger.error("sp\xe4m")
-        self.handled.wait()
+        self.handled.wait(support.LONG_TIMEOUT)
         self.assertEqual(self.log_output, b'<11>sp\xc3\xa4m')
         self.handled.clear()
         self.sl_hdlr.ident = "h\xe4m-"
         logger.error("sp\xe4m")
-        self.handled.wait()
+        self.handled.wait(support.LONG_TIMEOUT)
         self.assertEqual(self.log_output, b'<11>h\xc3\xa4m-sp\xc3\xa4m')
 
     def test_udp_reconnection(self):
@@ -1999,7 +1999,7 @@ class SysLogHandlerTest(BaseTest):
         self.sl_hdlr.close()
         self.handled.clear()
         logger.error("sp\xe4m")
-        self.handled.wait(0.1)
+        self.handled.wait(support.LONG_TIMEOUT)
         self.assertEqual(self.log_output, b'<11>sp\xc3\xa4m\x00')
 
 @unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
diff --git a/Misc/NEWS.d/next/Tests/2023-07-25-14-36-33.gh-issue-107237.y1pY79.rst b/Misc/NEWS.d/next/Tests/2023-07-25-14-36-33.gh-issue-107237.y1pY79.rst
new file mode 100644 (file)
index 0000000..a04f7ee
--- /dev/null
@@ -0,0 +1,2 @@
+``test_logging``: Fix ``test_udp_reconnection()`` by increasing the timeout
+from 100 ms to 5 minutes (LONG_TIMEOUT). Patch by Victor Stinner.