diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-03-26 17:36:42 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-03-26 17:36:42 (GMT) |
commit | b651949f53134776a6bdda311832d0d59648013f (patch) | |
tree | 8b1c1254953dfe58fcba2aecb921e508c3ccc279 /Lib | |
parent | 8d9a4628c35811a803bde626c76573c722beea03 (diff) | |
download | cpython-b651949f53134776a6bdda311832d0d59648013f.zip cpython-b651949f53134776a6bdda311832d0d59648013f.tar.gz cpython-b651949f53134776a6bdda311832d0d59648013f.tar.bz2 |
test_urllibnet: make it so that transient_internet() applies to the
whole HTTP exchange, not only the opening.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_urllibnet.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py index c885103..a019ddd 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. |