summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r--Lib/test/test_logging.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 2e5f647..e34fe45 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -22,6 +22,7 @@ import logging
import logging.handlers
import logging.config
+
import codecs
import configparser
import copy
@@ -2095,6 +2096,18 @@ class SysLogHandlerTest(BaseTest):
self.handled.wait(support.LONG_TIMEOUT)
self.assertEqual(self.log_output, b'<11>sp\xc3\xa4m\x00')
+ @patch('socket.socket')
+ def test_tcp_timeout(self, mock_socket):
+ instance_mock_sock = mock_socket.return_value
+ instance_mock_sock.connect.side_effect = socket.timeout
+
+ with self.assertRaises(socket.timeout):
+ logging.handlers.SysLogHandler(address=('localhost', 514),
+ socktype=socket.SOCK_STREAM,
+ timeout=1)
+
+ instance_mock_sock.close.assert_called()
+
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
class UnixSysLogHandlerTest(SysLogHandlerTest):