mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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.
This commit is contained in:
parent
3c8a5b459d
commit
16994912c9
37 changed files with 472 additions and 429 deletions
|
@ -32,6 +32,7 @@ from asyncio import proactor_events
|
|||
from asyncio import selector_events
|
||||
from test.test_asyncio import utils as test_utils
|
||||
from test import support
|
||||
from test.support import socket_helper
|
||||
from test.support import ALWAYS_EQ, LARGEST, SMALLEST
|
||||
|
||||
|
||||
|
@ -517,7 +518,7 @@ class EventLoopTestsMixin:
|
|||
lambda: MyProto(loop=self.loop), *httpd.address)
|
||||
self._basetest_create_connection(conn_fut)
|
||||
|
||||
@support.skip_unless_bind_unix_socket
|
||||
@socket_helper.skip_unless_bind_unix_socket
|
||||
def test_create_unix_connection(self):
|
||||
# Issue #20682: On Mac OS X Tiger, getsockname() returns a
|
||||
# zero-length address for UNIX socket.
|
||||
|
@ -619,7 +620,7 @@ class EventLoopTestsMixin:
|
|||
self._test_create_ssl_connection(httpd, create_connection,
|
||||
peername=httpd.address)
|
||||
|
||||
@support.skip_unless_bind_unix_socket
|
||||
@socket_helper.skip_unless_bind_unix_socket
|
||||
@unittest.skipIf(ssl is None, 'No ssl module')
|
||||
def test_create_ssl_unix_connection(self):
|
||||
# Issue #20682: On Mac OS X Tiger, getsockname() returns a
|
||||
|
@ -638,7 +639,7 @@ class EventLoopTestsMixin:
|
|||
|
||||
def test_create_connection_local_addr(self):
|
||||
with test_utils.run_test_server() as httpd:
|
||||
port = support.find_unused_port()
|
||||
port = socket_helper.find_unused_port()
|
||||
f = self.loop.create_connection(
|
||||
lambda: MyProto(loop=self.loop),
|
||||
*httpd.address, local_addr=(httpd.address[0], port))
|
||||
|
@ -843,7 +844,7 @@ class EventLoopTestsMixin:
|
|||
|
||||
return server, path
|
||||
|
||||
@support.skip_unless_bind_unix_socket
|
||||
@socket_helper.skip_unless_bind_unix_socket
|
||||
def test_create_unix_server(self):
|
||||
proto = MyProto(loop=self.loop)
|
||||
server, path = self._make_unix_server(lambda: proto)
|
||||
|
@ -935,7 +936,7 @@ class EventLoopTestsMixin:
|
|||
# stop serving
|
||||
server.close()
|
||||
|
||||
@support.skip_unless_bind_unix_socket
|
||||
@socket_helper.skip_unless_bind_unix_socket
|
||||
@unittest.skipIf(ssl is None, 'No ssl module')
|
||||
def test_create_unix_server_ssl(self):
|
||||
proto = MyProto(loop=self.loop)
|
||||
|
@ -995,7 +996,7 @@ class EventLoopTestsMixin:
|
|||
self.assertIsNone(proto.transport)
|
||||
server.close()
|
||||
|
||||
@support.skip_unless_bind_unix_socket
|
||||
@socket_helper.skip_unless_bind_unix_socket
|
||||
@unittest.skipIf(ssl is None, 'No ssl module')
|
||||
def test_create_unix_server_ssl_verify_failed(self):
|
||||
proto = MyProto(loop=self.loop)
|
||||
|
@ -1055,7 +1056,7 @@ class EventLoopTestsMixin:
|
|||
self.assertIsNone(proto.transport)
|
||||
server.close()
|
||||
|
||||
@support.skip_unless_bind_unix_socket
|
||||
@socket_helper.skip_unless_bind_unix_socket
|
||||
@unittest.skipIf(ssl is None, 'No ssl module')
|
||||
def test_create_unix_server_ssl_verified(self):
|
||||
proto = MyProto(loop=self.loop)
|
||||
|
@ -1148,7 +1149,7 @@ class EventLoopTestsMixin:
|
|||
|
||||
server.close()
|
||||
|
||||
@unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 not supported or enabled')
|
||||
@unittest.skipUnless(socket_helper.IPV6_ENABLED, 'IPv6 not supported or enabled')
|
||||
def test_create_server_dual_stack(self):
|
||||
f_proto = self.loop.create_future()
|
||||
|
||||
|
@ -1160,7 +1161,7 @@ class EventLoopTestsMixin:
|
|||
try_count = 0
|
||||
while True:
|
||||
try:
|
||||
port = support.find_unused_port()
|
||||
port = socket_helper.find_unused_port()
|
||||
f = self.loop.create_server(TestMyProto, host=None, port=port)
|
||||
server = self.loop.run_until_complete(f)
|
||||
except OSError as ex:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue