]> granicus.if.org Git - python/commitdiff
using support.transient_internet helper method in the urllib2net test.
authorSenthil Kumaran <senthil@uthcode.com>
Sun, 31 Jul 2011 03:45:14 +0000 (11:45 +0800)
committerSenthil Kumaran <senthil@uthcode.com>
Sun, 31 Jul 2011 03:45:14 +0000 (11:45 +0800)
Lib/test/test_urllib2net.py

index cd225c90fd59175c990851ed57aa50258f826d4f..54f4e0c6ca442a21fa3c7f2053f499aee202cd9c 100644 (file)
@@ -178,17 +178,21 @@ class OtherNetworkTests(unittest.TestCase):
         # Some sites do not send Connection: close header.
         # Verify that those work properly. (#issue12576)
 
-        try:
-            with urllib.request.urlopen('http://www.imdb.com') as res:
-                pass
-        except ValueError as e:
-            self.fail("urlopen failed for sites not sending Connection:close")
-        else:
-            self.assertTrue(res)
+        URL = 'http://www.imdb.com' # mangles Connection:close
+
+        with support.transient_internet(URL):
+            try:
+                with urllib.request.urlopen(URL) as res:
+                    pass
+            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')
-        res = req.read()
-        self.assertTrue(res)
+            req = urllib.request.urlopen(URL)
+            res = req.read()
+            self.assertTrue(res)
 
     def _test_urls(self, urls, handlers, retry=True):
         import time