summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_timeout.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_timeout.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_timeout.py')
-rw-r--r--Lib/test/test_timeout.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/test/test_timeout.py b/Lib/test/test_timeout.py
index ff41b13..c0952c7 100644
--- a/Lib/test/test_timeout.py
+++ b/Lib/test/test_timeout.py
@@ -3,6 +3,7 @@
import functools
import unittest
from test import support
+from test.support import socket_helper
# This requires the 'network' resource as given on the regrtest command line.
skip_expected = not support.is_resource_enabled('network')
@@ -110,7 +111,7 @@ class TimeoutTestCase(unittest.TestCase):
# solution.
fuzz = 2.0
- localhost = support.HOST
+ localhost = socket_helper.HOST
def setUp(self):
raise NotImplementedError()
@@ -240,14 +241,14 @@ class TCPTimeoutTestCase(TimeoutTestCase):
def testAcceptTimeout(self):
# Test accept() timeout
- support.bind_port(self.sock, self.localhost)
+ socket_helper.bind_port(self.sock, self.localhost)
self.sock.listen()
self._sock_operation(1, 1.5, 'accept')
def testSend(self):
# Test send() timeout
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as serv:
- support.bind_port(serv, self.localhost)
+ socket_helper.bind_port(serv, self.localhost)
serv.listen()
self.sock.connect(serv.getsockname())
# Send a lot of data in order to bypass buffering in the TCP stack.
@@ -256,7 +257,7 @@ class TCPTimeoutTestCase(TimeoutTestCase):
def testSendto(self):
# Test sendto() timeout
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as serv:
- support.bind_port(serv, self.localhost)
+ socket_helper.bind_port(serv, self.localhost)
serv.listen()
self.sock.connect(serv.getsockname())
# The address argument is ignored since we already connected.
@@ -266,7 +267,7 @@ class TCPTimeoutTestCase(TimeoutTestCase):
def testSendall(self):
# Test sendall() timeout
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as serv:
- support.bind_port(serv, self.localhost)
+ socket_helper.bind_port(serv, self.localhost)
serv.listen()
self.sock.connect(serv.getsockname())
# Send a lot of data in order to bypass buffering in the TCP stack.
@@ -285,7 +286,7 @@ class UDPTimeoutTestCase(TimeoutTestCase):
def testRecvfromTimeout(self):
# Test recvfrom() timeout
# Prevent "Address already in use" socket exceptions
- support.bind_port(self.sock, self.localhost)
+ socket_helper.bind_port(self.sock, self.localhost)
self._sock_operation(1, 1.5, 'recvfrom', 1024)