summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2010-10-17 11:01:46 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2010-10-17 11:01:46 (GMT)
commit378e6db834488d585f90f358d23d7d33a81ec854 (patch)
tree14f1b2bd842ce76ee0437b9cc2677220abfb7f5a /Lib
parent397cd8a1fc22c8cbc6f5840a1813fd0f418ee841 (diff)
downloadcpython-378e6db834488d585f90f358d23d7d33a81ec854.zip
cpython-378e6db834488d585f90f358d23d7d33a81ec854.tar.gz
cpython-378e6db834488d585f90f358d23d7d33a81ec854.tar.bz2
Merged revisions 85630 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r85630 | senthil.kumaran | 2010-10-17 16:22:12 +0530 (Sun, 17 Oct 2010) | 3 lines Fix Issue10119 - test_urllibnet failure when using support.transient_internet. ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_urllibnet.py30
1 files changed, 10 insertions, 20 deletions
diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py
index 37cad42..bac2049 100644
--- a/Lib/test/test_urllibnet.py
+++ b/Lib/test/test_urllibnet.py
@@ -11,21 +11,6 @@ import email.message
import time
-def _open_with_retry(func, host, *args, **kwargs):
- # Connecting to remote hosts is flaky. Make it more robust
- # by retrying the connection several times.
- last_exc = None
- for i in range(3):
- try:
- return func(host, *args, **kwargs)
- except IOError as err:
- last_exc = err
- continue
- except:
- raise
- raise last_exc
-
-
class URLTimeoutTest(unittest.TestCase):
TIMEOUT = 10.0
@@ -37,7 +22,8 @@ class URLTimeoutTest(unittest.TestCase):
socket.setdefaulttimeout(None)
def testURLread(self):
- f = _open_with_retry(urllib.request.urlopen, "http://www.python.org/")
+ with support.transient_internet("www.python.org"):
+ f = urllib.request.urlopen("http://www.python.org/")
x = f.read()
class urlopenNetworkTests(unittest.TestCase):
@@ -55,8 +41,10 @@ class urlopenNetworkTests(unittest.TestCase):
"""
- def urlopen(self, *args):
- return _open_with_retry(urllib.request.urlopen, *args)
+ def urlopen(self, *args, **kwargs):
+ resource = args[0]
+ with support.transient_internet(resource):
+ return urllib.request.urlopen(*args, **kwargs)
def test_basic(self):
# Simple test expected to pass.
@@ -119,7 +107,7 @@ class urlopenNetworkTests(unittest.TestCase):
# test can't pass on Windows.
return
# Make sure fd returned by fileno is valid.
- open_url = self.urlopen("http://www.python.org/")
+ open_url = self.urlopen("http://www.python.org/", timeout=None)
fd = open_url.fileno()
FILE = os.fdopen(fd, encoding='utf-8')
try:
@@ -146,7 +134,9 @@ class urlretrieveNetworkTests(unittest.TestCase):
"""Tests urllib.request.urlretrieve using the network."""
def urlretrieve(self, *args):
- return _open_with_retry(urllib.request.urlretrieve, *args)
+ resource = args[0]
+ with support.transient_internet(resource):
+ return urllib.request.urlretrieve(*args)
def test_basic(self):
# Test basic functionality.