summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-03-26 18:36:42 +0100
committerAntoine Pitrou <solipsis@pitrou.net>2011-03-26 18:36:42 +0100
commit5a23ba83ebd1b0ef37d17fe7fb13895ebc779f07 (patch)
treebafeb604eba488f40c559648d3061c0214cfe416
parent6dbb38b1e41a6cd53bed67e6b3720fac667d8fe8 (diff)
downloadcpython-5a23ba83ebd1b0ef37d17fe7fb13895ebc779f07.tar.gz
test_urllibnet: make it so that transient_internet() applies to the
whole HTTP exchange, not only the opening.
-rw-r--r--Lib/test/test_urllibnet.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py
index c8851031e8..a019ddd2a6 100644
--- a/Lib/test/test_urllibnet.py
+++ b/Lib/test/test_urllibnet.py
@@ -43,8 +43,10 @@ class urlopenNetworkTests(unittest.TestCase):
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 +137,10 @@ class urlretrieveNetworkTests(unittest.TestCase):
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.