diff options
Diffstat (limited to 'Lib/test/test_ssl.py')
-rw-r--r-- | Lib/test/test_ssl.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 4184665..dafdb6c 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -4,6 +4,7 @@ import sys import unittest import unittest.mock from test import support +from test.support import socket_helper import socket import select import time @@ -33,7 +34,7 @@ Py_DEBUG = hasattr(sys, 'gettotalrefcount') Py_DEBUG_WIN32 = Py_DEBUG and sys.platform == 'win32' PROTOCOLS = sorted(ssl._PROTOCOL_NAMES) -HOST = support.HOST +HOST = socket_helper.HOST IS_LIBRESSL = ssl.OPENSSL_VERSION.startswith('LibreSSL') IS_OPENSSL_1_1_0 = not IS_LIBRESSL and ssl.OPENSSL_VERSION_INFO >= (1, 1, 0) IS_OPENSSL_1_1_1 = not IS_LIBRESSL and ssl.OPENSSL_VERSION_INFO >= (1, 1, 1) @@ -762,7 +763,7 @@ class BasicSocketTests(unittest.TestCase): fail(cert, 'example.net') # -- IPv6 matching -- - if support.IPV6_ENABLED: + if socket_helper.IPV6_ENABLED: cert = {'subject': ((('commonName', 'example.com'),),), 'subjectAltName': ( ('DNS', 'example.com'), @@ -845,7 +846,7 @@ class BasicSocketTests(unittest.TestCase): ssl._inet_paton(invalid) for ipaddr in ['127.0.0.1', '192.168.0.1']: self.assertTrue(ssl._inet_paton(ipaddr)) - if support.IPV6_ENABLED: + if socket_helper.IPV6_ENABLED: for ipaddr in ['::1', '2001:db8:85a3::8a2e:370:7334']: self.assertTrue(ssl._inet_paton(ipaddr)) @@ -1073,7 +1074,7 @@ class BasicSocketTests(unittest.TestCase): def test_connect_ex_error(self): server = socket.socket(socket.AF_INET) self.addCleanup(server.close) - port = support.bind_port(server) # Reserve port but don't listen + port = socket_helper.bind_port(server) # Reserve port but don't listen s = test_wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED) self.addCleanup(s.close) @@ -2256,7 +2257,7 @@ class NetworkedTests(unittest.TestCase): self.skipTest("REMOTE_HOST responded too quickly") self.assertIn(rc, (errno.EAGAIN, errno.EWOULDBLOCK)) - @unittest.skipUnless(support.IPV6_ENABLED, 'Needs IPv6') + @unittest.skipUnless(socket_helper.IPV6_ENABLED, 'Needs IPv6') def test_get_server_certificate_ipv6(self): with support.transient_internet('ipv6.google.com'): _test_get_server_certificate(self, 'ipv6.google.com', 443) @@ -2511,7 +2512,7 @@ class ThreadedEchoServer(threading.Thread): self.connectionchatty = connectionchatty self.starttls_server = starttls_server self.sock = socket.socket() - self.port = support.bind_port(self.sock) + self.port = socket_helper.bind_port(self.sock) self.flag = None self.active = False self.selected_npn_protocols = [] @@ -2624,7 +2625,7 @@ class AsyncoreEchoServer(threading.Thread): def __init__(self, certfile): self.certfile = certfile sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.port = support.bind_port(sock, '') + self.port = socket_helper.bind_port(sock, '') asyncore.dispatcher.__init__(self, sock) self.listen(5) @@ -3144,7 +3145,7 @@ class ThreadedTests(unittest.TestCase): listener_gone = threading.Event() s = socket.socket() - port = support.bind_port(s, HOST) + port = socket_helper.bind_port(s, HOST) # `listener` runs in a thread. It sits in an accept() until # the main thread connects. Then it rudely closes the socket, @@ -3640,7 +3641,7 @@ class ThreadedTests(unittest.TestCase): # Issue #5103: SSL handshake must respect the socket timeout server = socket.socket(socket.AF_INET) host = "127.0.0.1" - port = support.bind_port(server) + port = socket_helper.bind_port(server) started = threading.Event() finish = False @@ -3694,7 +3695,7 @@ class ThreadedTests(unittest.TestCase): context.load_cert_chain(SIGNED_CERTFILE) server = socket.socket(socket.AF_INET) host = "127.0.0.1" - port = support.bind_port(server) + port = socket_helper.bind_port(server) server = context.wrap_socket(server, server_side=True) self.assertTrue(server.server_side) |