Commit e324c573 authored by Senthil Kumaran's avatar Senthil Kumaran

using support.transient_internet helper method in the urllib2net test.

parent 59256329
...@@ -178,17 +178,21 @@ class OtherNetworkTests(unittest.TestCase): ...@@ -178,17 +178,21 @@ class OtherNetworkTests(unittest.TestCase):
# Some sites do not send Connection: close header. # Some sites do not send Connection: close header.
# Verify that those work properly. (#issue12576) # Verify that those work properly. (#issue12576)
try: URL = 'http://www.imdb.com' # mangles Connection:close
with urllib.request.urlopen('http://www.imdb.com') as res:
pass with support.transient_internet(URL):
except ValueError as e: try:
self.fail("urlopen failed for sites not sending Connection:close") with urllib.request.urlopen(URL) as res:
else: pass
self.assertTrue(res) except ValueError as e:
self.fail("urlopen failed for site not sending \
Connection:close")
else:
self.assertTrue(res)
req = urllib.request.urlopen('http://www.imdb.com') req = urllib.request.urlopen(URL)
res = req.read() res = req.read()
self.assertTrue(res) self.assertTrue(res)
def _test_urls(self, urls, handlers, retry=True): def _test_urls(self, urls, handlers, retry=True):
import time import time
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment