summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2019-12-10 21:09:23 (GMT)
committerGitHub <noreply@github.com>2019-12-10 21:09:23 (GMT)
commit1d0f9b316a290f0e1f330fdbceb027deb96ce109 (patch)
treeaa11a994386b9fb60f07d161810a4c4399775a03 /Lib
parentc98b0199a984430312833ef403d265be314f7244 (diff)
downloadcpython-1d0f9b316a290f0e1f330fdbceb027deb96ce109.zip
cpython-1d0f9b316a290f0e1f330fdbceb027deb96ce109.tar.gz
cpython-1d0f9b316a290f0e1f330fdbceb027deb96ce109.tar.bz2
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.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_nntplib.py14
-rw-r--r--Lib/test/test_urllib2net.py4
-rw-r--r--Lib/test/test_urllibnet.py4
3 files changed, 12 insertions, 10 deletions
diff --git a/Lib/test/test_nntplib.py b/Lib/test/test_nntplib.py
index 618b403..daa4a79 100644
--- a/Lib/test/test_nntplib.py
+++ b/Lib/test/test_nntplib.py
@@ -19,7 +19,6 @@ except ImportError:
ssl = None
-TIMEOUT = 30
certfile = os.path.join(os.path.dirname(__file__), 'keycert3.pem')
if ssl is not None:
@@ -270,12 +269,18 @@ class NetworkedNNTPTestsMixin:
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 @@ class NetworkedNNTPTests(NetworkedNNTPTestsMixin, unittest.TestCase):
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"
diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py
index bb0500e..b3a5e89 100644
--- a/Lib/test/test_urllib2net.py
+++ b/Lib/test/test_urllib2net.py
@@ -10,8 +10,6 @@ import sys
support.requires("network")
-TIMEOUT = 60 # seconds
-
def _retry_thrice(func, exc, *args, **kwargs):
for i in range(3):
@@ -227,7 +225,7 @@ class OtherNetworkTests(unittest.TestCase):
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:
diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py
index 848ab84..422d529 100644
--- a/Lib/test/test_urllibnet.py
+++ b/Lib/test/test_urllibnet.py
@@ -16,10 +16,8 @@ support.requires('network')
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)