summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorRoss <rrhodes@users.noreply.github.com>2021-01-01 17:20:25 (GMT)
committerGitHub <noreply@github.com>2021-01-01 17:20:25 (GMT)
commit3bf05327c2b25d42b92795d9d280288c22a0963d (patch)
tree608f0d4a616d760f154d4a8a73e837e5fc92fb30 /Lib/test
parentde6f20a6de48d63066b2cf5b317f50629f01d74a (diff)
downloadcpython-3bf05327c2b25d42b92795d9d280288c22a0963d.zip
cpython-3bf05327c2b25d42b92795d9d280288c22a0963d.tar.gz
cpython-3bf05327c2b25d42b92795d9d280288c22a0963d.tar.bz2
bpo-42756: Configure LMTP Unix-domain socket to use global default timeout when timeout not provided (GH-23969)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/mock_socket.py7
-rw-r--r--Lib/test/test_smtplib.py11
2 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/mock_socket.py b/Lib/test/mock_socket.py
index cda4db2..c7abddc 100644
--- a/Lib/test/mock_socket.py
+++ b/Lib/test/mock_socket.py
@@ -107,6 +107,9 @@ class MockSocket:
def close(self):
pass
+ def connect(self, host):
+ pass
+
def socket(family=None, type=None, proto=None):
return MockSocket(family)
@@ -152,8 +155,12 @@ error = socket_module.error
# Constants
+_GLOBAL_DEFAULT_TIMEOUT = socket_module._GLOBAL_DEFAULT_TIMEOUT
AF_INET = socket_module.AF_INET
AF_INET6 = socket_module.AF_INET6
SOCK_STREAM = socket_module.SOCK_STREAM
SOL_SOCKET = None
SO_REUSEADDR = None
+
+if hasattr(socket_module, 'AF_UNIX'):
+ AF_UNIX = socket_module.AF_UNIX
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index 9198538..1ad45d8 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -165,6 +165,17 @@ class LMTPGeneralTests(GeneralTests, unittest.TestCase):
client = smtplib.LMTP
+ @unittest.skipUnless(hasattr(socket, 'AF_UNIX'), "test requires Unix domain socket")
+ def testUnixDomainSocketTimeoutDefault(self):
+ local_host = '/some/local/lmtp/delivery/program'
+ mock_socket.reply_with(b"220 Hello world")
+ try:
+ client = self.client(local_host, self.port)
+ finally:
+ mock_socket.setdefaulttimeout(None)
+ self.assertIsNone(client.sock.gettimeout())
+ client.close()
+
def testTimeoutZero(self):
super().testTimeoutZero()
local_host = '/some/local/lmtp/delivery/program'