[Python-checkins] cpython (merge 3.2 -> default): Merge from 3.2

antoine.pitrou python-checkins at python.org
Sat Mar 26 18:40:07 CET 2011


http://hg.python.org/cpython/rev/09fc6a2b68fd
changeset:   68974:09fc6a2b68fd
parent:      68971:402d54e97686
parent:      68973:aa46bdbe641d
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Sat Mar 26 18:39:55 2011 +0100
summary:
  Merge from 3.2

files:
  Lib/test/test_urllibnet.py |  15 ++++++++++-----
  1 files changed, 10 insertions(+), 5 deletions(-)


diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py
--- a/Lib/test/test_urllibnet.py
+++ b/Lib/test/test_urllibnet.py
@@ -12,6 +12,7 @@
 
 
 class URLTimeoutTest(unittest.TestCase):
+    # XXX this test doesn't seem to test anything useful.
 
     TIMEOUT = 30.0
 
@@ -24,7 +25,7 @@
     def testURLread(self):
         with support.transient_internet("www.python.org"):
             f = urllib.request.urlopen("http://www.python.org/")
-        x = f.read()
+            x = f.read()
 
 class urlopenNetworkTests(unittest.TestCase):
     """Tests urllib.reqest.urlopen using the network.
@@ -43,8 +44,10 @@
 
     def urlopen(self, *args, **kwargs):
         resource = args[0]
-        with support.transient_internet(resource):
-            return urllib.request.urlopen(*args, **kwargs)
+        cm = support.transient_internet(resource)
+        cm.__enter__()
+        self.addCleanup(cm.__exit__, None, None, None)
+        return urllib.request.urlopen(*args, **kwargs)
 
     def test_basic(self):
         # Simple test expected to pass.
@@ -135,8 +138,10 @@
 
     def urlretrieve(self, *args):
         resource = args[0]
-        with support.transient_internet(resource):
-            return urllib.request.urlretrieve(*args)
+        cm = support.transient_internet(resource)
+        cm.__enter__()
+        self.addCleanup(cm.__exit__, None, None, None)
+        return urllib.request.urlretrieve(*args)
 
     def test_basic(self):
         # Test basic functionality.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list