summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_events.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-04-25 07:06:29 (GMT)
committerGitHub <noreply@github.com>2020-04-25 07:06:29 (GMT)
commit16994912c93e8e5db7365d48b75d67d3f70dd7b2 (patch)
tree248f177a93676406af6d6ae977bed868aa2d1a34 /Lib/test/test_asyncio/test_events.py
parent3c8a5b459d68b4337776ada1e04f5b33f90a2275 (diff)
downloadcpython-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_asyncio/test_events.py')
-rw-r--r--Lib/test/test_asyncio/test_events.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index 1f71c1f..aa4daca 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -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: