using support.transient_internet helper method in the urllib2net test.

This commit is contained in:
Senthil Kumaran 2011-07-31 11:46:24 +08:00
commit 2f7c695b97
1 changed files with 14 additions and 10 deletions

View File

@ -178,15 +178,19 @@ class OtherNetworkTests(unittest.TestCase):
# Some sites do not send Connection: close header.
# Verify that those work properly. (#issue12576)
URL = 'http://www.imdb.com' # mangles Connection:close
with support.transient_internet(URL):
try:
with urllib.request.urlopen('http://www.imdb.com') as res:
with urllib.request.urlopen(URL) as res:
pass
except ValueError as e:
self.fail("urlopen failed for sites not sending Connection:close")
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()
self.assertTrue(res)