Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e324c57

Browse files
committed
using support.transient_internet helper method in the urllib2net test.
1 parent 5925632 commit e324c57

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

Lib/test/test_urllib2net.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,21 @@ def test_sites_no_connection_close(self):
178178
# Some sites do not send Connection: close header.
179179
# Verify that those work properly. (#issue12576)
180180

181-
try:
182-
with urllib.request.urlopen('http://www.imdb.com') as res:
183-
pass
184-
except ValueError as e:
185-
self.fail("urlopen failed for sites not sending Connection:close")
186-
else:
187-
self.assertTrue(res)
181+
URL = 'http://www.imdb.com' # mangles Connection:close
182+
183+
with support.transient_internet(URL):
184+
try:
185+
with urllib.request.urlopen(URL) as res:
186+
pass
187+
except ValueError as e:
188+
self.fail("urlopen failed for site not sending \
189+
Connection:close")
190+
else:
191+
self.assertTrue(res)
188192

189-
req = urllib.request.urlopen('http://www.imdb.com')
190-
res = req.read()
191-
self.assertTrue(res)
193+
req = urllib.request.urlopen(URL)
194+
res = req.read()
195+
self.assertTrue(res)
192196

193197
def _test_urls(self, urls, handlers, retry=True):
194198
import time

0 commit comments

Comments
 (0)