test_urllibnet: make it so that transient_internet() applies to the

whole HTTP exchange, not only the opening.
This commit is contained in:
Antoine Pitrou 2011-03-26 18:36:42 +01:00
parent 8d9a4628c3
commit b651949f53
1 changed files with 8 additions and 4 deletions

View File

@ -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.