bpo-38614: Add timeout constants to test.support (GH-16964)
Add timeout constants to test.support:
* LOOPBACK_TIMEOUT
* INTERNET_TIMEOUT
* SHORT_TIMEOUT
* LONG_TIMEOUT
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index b745490..184c67c 100755
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -37,7 +37,6 @@
HOST = support.HOST
# test unicode string and carriage return
MSG = 'Michael Gilfix was here\u1234\r\n'.encode('utf-8')
-MAIN_TIMEOUT = 60.0
VSOCKPORT = 1234
AIX = platform.system() == "AIX"
@@ -2527,7 +2526,7 @@
# Time in seconds to wait before considering a test failed, or
# None for no timeout. Not all tests actually set a timeout.
- fail_timeout = 3.0
+ fail_timeout = support.LOOPBACK_TIMEOUT
def setUp(self):
self.misc_event = threading.Event()
@@ -4320,7 +4319,7 @@
self.addCleanup(signal.signal, signal.SIGALRM, orig_alrm_handler)
# Timeout for socket operations
- timeout = 4.0
+ timeout = support.LOOPBACK_TIMEOUT
# Provide setAlarm() method to schedule delivery of SIGALRM after
# given number of seconds, or cancel it if zero, and an
@@ -4610,7 +4609,7 @@
self.event.set()
- read, write, err = select.select([self.serv], [], [], MAIN_TIMEOUT)
+ read, write, err = select.select([self.serv], [], [], support.LONG_TIMEOUT)
if self.serv not in read:
self.fail("Error trying to do accept after select.")
@@ -4638,7 +4637,7 @@
self.event.set()
- read, write, err = select.select([conn], [], [], MAIN_TIMEOUT)
+ read, write, err = select.select([conn], [], [], support.LONG_TIMEOUT)
if conn not in read:
self.fail("Error during select call to non-blocking socket.")
@@ -5838,8 +5837,7 @@
FILESIZE = (10 * 1024 * 1024) # 10 MiB
BUFSIZE = 8192
FILEDATA = b""
- # bpo-37553: This is taking longer than 2 seconds on Windows ARM32 buildbot
- TIMEOUT = 10 if sys.platform == 'win32' and platform.machine() == 'ARM' else 2
+ TIMEOUT = support.LOOPBACK_TIMEOUT
@classmethod
def setUpClass(cls):
@@ -5865,7 +5863,7 @@
support.unlink(support.TESTFN)
def accept_conn(self):
- self.serv.settimeout(MAIN_TIMEOUT)
+ self.serv.settimeout(support.LONG_TIMEOUT)
conn, addr = self.serv.accept()
conn.settimeout(self.TIMEOUT)
self.addCleanup(conn.close)
@@ -6369,7 +6367,7 @@
class CreateServerFunctionalTest(unittest.TestCase):
- timeout = 3
+ timeout = support.LOOPBACK_TIMEOUT
def setUp(self):
self.thread = None