diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-04-25 07:06:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-25 07:06:29 (GMT) |
commit | 16994912c93e8e5db7365d48b75d67d3f70dd7b2 (patch) | |
tree | 248f177a93676406af6d6ae977bed868aa2d1a34 /Lib/test/test_asyncore.py | |
parent | 3c8a5b459d68b4337776ada1e04f5b33f90a2275 (diff) | |
download | cpython-16994912c93e8e5db7365d48b75d67d3f70dd7b2.zip cpython-16994912c93e8e5db7365d48b75d67d3f70dd7b2.tar.gz cpython-16994912c93e8e5db7365d48b75d67d3f70dd7b2.tar.bz2 |
bpo-40275: Avoid importing socket in test.support (GH-19603)
* Move socket related functions from test.support to socket_helper.
* Import socket, nntplib and urllib.error lazily in transient_internet().
* Remove importing multiprocess.
Diffstat (limited to 'Lib/test/test_asyncore.py')
-rw-r--r-- | Lib/test/test_asyncore.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py index 6c84ac4..3c3abe4 100644 --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -10,6 +10,7 @@ import struct import threading from test import support +from test.support import socket_helper from io import BytesIO if support.PGO: @@ -91,7 +92,7 @@ def bind_af_aware(sock, addr): if HAS_UNIX_SOCKETS and sock.family == socket.AF_UNIX: # Make sure the path doesn't exist. support.unlink(addr) - support.bind_unix_socket(sock, addr) + socket_helper.bind_unix_socket(sock, addr) else: sock.bind(addr) @@ -327,7 +328,7 @@ class DispatcherWithSendTests(unittest.TestCase): evt = threading.Event() sock = socket.socket() sock.settimeout(3) - port = support.bind_port(sock) + port = socket_helper.bind_port(sock) cap = BytesIO() args = (evt, cap, sock) @@ -341,7 +342,7 @@ class DispatcherWithSendTests(unittest.TestCase): data = b"Suppose there isn't a 16-ton weight?" d = dispatcherwithsend_noread() d.create_socket() - d.connect((support.HOST, port)) + d.connect((socket_helper.HOST, port)) # give time for socket to connect time.sleep(0.1) @@ -791,12 +792,12 @@ class BaseTestAPI: class TestAPI_UseIPv4Sockets(BaseTestAPI): family = socket.AF_INET - addr = (support.HOST, 0) + addr = (socket_helper.HOST, 0) -@unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 support required') +@unittest.skipUnless(socket_helper.IPV6_ENABLED, 'IPv6 support required') class TestAPI_UseIPv6Sockets(BaseTestAPI): family = socket.AF_INET6 - addr = (support.HOSTv6, 0) + addr = (socket_helper.HOSTv6, 0) @unittest.skipUnless(HAS_UNIX_SOCKETS, 'Unix sockets required') class TestAPI_UseUnixSockets(BaseTestAPI): |