mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
bpo-38614: Use test.support.INTERNET_TIMEOUT constant (GH-17565)
Replace hardcoded timeout constants in tests with INTERNET_TIMEOUT of test.support, so it's easier to ajdust this timeout for all tests at once.
This commit is contained in:
parent
c98b0199a9
commit
1d0f9b316a
3 changed files with 12 additions and 10 deletions
|
|
@ -19,7 +19,6 @@
|
|||
ssl = None
|
||||
|
||||
|
||||
TIMEOUT = 30
|
||||
certfile = os.path.join(os.path.dirname(__file__), 'keycert3.pem')
|
||||
|
||||
if ssl is not None:
|
||||
|
|
@ -270,12 +269,18 @@ def is_connected():
|
|||
return True
|
||||
|
||||
try:
|
||||
with self.NNTP_CLASS(self.NNTP_HOST, timeout=TIMEOUT, usenetrc=False) as server:
|
||||
server = self.NNTP_CLASS(self.NNTP_HOST,
|
||||
timeout=support.INTERNET_TIMEOUT,
|
||||
usenetrc=False)
|
||||
with server:
|
||||
self.assertTrue(is_connected())
|
||||
self.assertTrue(server.help())
|
||||
self.assertFalse(is_connected())
|
||||
|
||||
with self.NNTP_CLASS(self.NNTP_HOST, timeout=TIMEOUT, usenetrc=False) as server:
|
||||
server = self.NNTP_CLASS(self.NNTP_HOST,
|
||||
timeout=support.INTERNET_TIMEOUT,
|
||||
usenetrc=False)
|
||||
with server:
|
||||
server.quit()
|
||||
self.assertFalse(is_connected())
|
||||
except SSLError as ssl_err:
|
||||
|
|
@ -307,7 +312,8 @@ def setUpClass(cls):
|
|||
support.requires("network")
|
||||
with support.transient_internet(cls.NNTP_HOST):
|
||||
try:
|
||||
cls.server = cls.NNTP_CLASS(cls.NNTP_HOST, timeout=TIMEOUT,
|
||||
cls.server = cls.NNTP_CLASS(cls.NNTP_HOST,
|
||||
timeout=support.INTERNET_TIMEOUT,
|
||||
usenetrc=False)
|
||||
except SSLError as ssl_err:
|
||||
# matches "[SSL: DH_KEY_TOO_SMALL] dh key too small"
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
support.requires("network")
|
||||
|
||||
TIMEOUT = 60 # seconds
|
||||
|
||||
|
||||
def _retry_thrice(func, exc, *args, **kwargs):
|
||||
for i in range(3):
|
||||
|
|
@ -227,7 +225,7 @@ def _test_urls(self, urls, handlers, retry=True):
|
|||
|
||||
with support.transient_internet(url):
|
||||
try:
|
||||
f = urlopen(url, req, TIMEOUT)
|
||||
f = urlopen(url, req, support.INTERNET_TIMEOUT)
|
||||
# urllib.error.URLError is a subclass of OSError
|
||||
except OSError as err:
|
||||
if expected_err:
|
||||
|
|
|
|||
|
|
@ -16,10 +16,8 @@
|
|||
class URLTimeoutTest(unittest.TestCase):
|
||||
# XXX this test doesn't seem to test anything useful.
|
||||
|
||||
TIMEOUT = 30.0
|
||||
|
||||
def setUp(self):
|
||||
socket.setdefaulttimeout(self.TIMEOUT)
|
||||
socket.setdefaulttimeout(support.INTERNET_TIMEOUT)
|
||||
|
||||
def tearDown(self):
|
||||
socket.setdefaulttimeout(None)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue