Index: Lib/test/test_urllibnet.py =================================================================== --- Lib/test/test_urllibnet.py (révision 80568) +++ Lib/test/test_urllibnet.py (copie de travail) @@ -18,11 +18,8 @@ return func(host, *args, **kwargs) except IOError, last_exc: continue - except: - raise raise last_exc - class URLTimeoutTest(unittest.TestCase): TIMEOUT = 10.0 @@ -34,8 +31,9 @@ socket.setdefaulttimeout(None) def testURLread(self): - f = _open_with_retry(urllib.urlopen, "http://www.python.org/") - x = f.read() + with test_support.transient_internet(timeout=None): + f = _open_with_retry(urllib.urlopen, "http://www.python.org/") + x = f.read() class urlopenNetworkTests(unittest.TestCase): """Tests urllib.urlopen using the network. @@ -53,7 +51,8 @@ """ def urlopen(self, *args): - return _open_with_retry(urllib.urlopen, *args) + with test_support.transient_internet(): + return _open_with_retry(urllib.urlopen, *args) def test_basic(self): # Simple test expected to pass. @@ -103,12 +102,13 @@ def test_getcode(self): # test getcode() with the fancy opener to get 404 error codes URL = "http://www.python.org/XXXinvalidXXX" - open_url = urllib.FancyURLopener().open(URL) - try: - code = open_url.getcode() - finally: - open_url.close() - self.assertEqual(code, 404) + with test_support.transient_internet(): + open_url = urllib.FancyURLopener().open(URL) + try: + code = open_url.getcode() + finally: + open_url.close() + self.assertEqual(code, 404) def test_fileno(self): if (sys.platform in ('win32',) or @@ -143,7 +143,8 @@ """Tests urllib.urlretrieve using the network.""" def urlretrieve(self, *args): - return _open_with_retry(urllib.urlretrieve, *args) + with test_support.transient_internet(): + return _open_with_retry(urllib.urlretrieve, *args) def test_basic(self): # Test basic functionality.