diff options
Diffstat (limited to 'Lib/test/test_urllib2net.py')
-rw-r--r-- | Lib/test/test_urllib2net.py | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py index b3a5e89..ba4c500 100644 --- a/Lib/test/test_urllib2net.py +++ b/Lib/test/test_urllib2net.py @@ -1,5 +1,6 @@ import unittest from test import support +from test.support import socket_helper from test.test_urllib2 import sanepathname2url import os @@ -86,7 +87,7 @@ class CloseSocketTest(unittest.TestCase): # calling .close() on urllib2's response objects should close the # underlying socket url = support.TEST_HTTP_URL - with support.transient_internet(url): + with socket_helper.transient_internet(url): response = _urlopen_with_retry(url) sock = response.fp self.assertFalse(sock.closed) @@ -159,7 +160,7 @@ class OtherNetworkTests(unittest.TestCase): def test_urlwithfrag(self): urlwith_frag = "http://www.pythontest.net/index.html#frag" - with support.transient_internet(urlwith_frag): + with socket_helper.transient_internet(urlwith_frag): req = urllib.request.Request(urlwith_frag) res = urllib.request.urlopen(req) self.assertEqual(res.geturl(), @@ -167,7 +168,7 @@ class OtherNetworkTests(unittest.TestCase): def test_redirect_url_withfrag(self): redirect_url_with_frag = "http://www.pythontest.net/redir/with_frag/" - with support.transient_internet(redirect_url_with_frag): + with socket_helper.transient_internet(redirect_url_with_frag): req = urllib.request.Request(redirect_url_with_frag) res = urllib.request.urlopen(req) self.assertEqual(res.geturl(), @@ -175,7 +176,7 @@ class OtherNetworkTests(unittest.TestCase): def test_custom_headers(self): url = support.TEST_HTTP_URL - with support.transient_internet(url): + with socket_helper.transient_internet(url): opener = urllib.request.build_opener() request = urllib.request.Request(url) self.assertFalse(request.header_items()) @@ -193,7 +194,7 @@ class OtherNetworkTests(unittest.TestCase): URL = 'http://www.imdb.com' # mangles Connection:close - with support.transient_internet(URL): + with socket_helper.transient_internet(URL): try: with urllib.request.urlopen(URL) as res: pass @@ -223,7 +224,7 @@ class OtherNetworkTests(unittest.TestCase): else: req = expected_err = None - with support.transient_internet(url): + with socket_helper.transient_internet(url): try: f = urlopen(url, req, support.INTERNET_TIMEOUT) # urllib.error.URLError is a subclass of OSError @@ -265,7 +266,7 @@ class TimeoutTest(unittest.TestCase): def test_http_basic(self): self.assertIsNone(socket.getdefaulttimeout()) url = support.TEST_HTTP_URL - with support.transient_internet(url, timeout=None): + with socket_helper.transient_internet(url, timeout=None): u = _urlopen_with_retry(url) self.addCleanup(u.close) self.assertIsNone(u.fp.raw._sock.gettimeout()) @@ -273,7 +274,7 @@ class TimeoutTest(unittest.TestCase): def test_http_default_timeout(self): self.assertIsNone(socket.getdefaulttimeout()) url = support.TEST_HTTP_URL - with support.transient_internet(url): + with socket_helper.transient_internet(url): socket.setdefaulttimeout(60) try: u = _urlopen_with_retry(url) @@ -285,7 +286,7 @@ class TimeoutTest(unittest.TestCase): def test_http_no_timeout(self): self.assertIsNone(socket.getdefaulttimeout()) url = support.TEST_HTTP_URL - with support.transient_internet(url): + with socket_helper.transient_internet(url): socket.setdefaulttimeout(60) try: u = _urlopen_with_retry(url, timeout=None) @@ -296,7 +297,7 @@ class TimeoutTest(unittest.TestCase): def test_http_timeout(self): url = support.TEST_HTTP_URL - with support.transient_internet(url): + with socket_helper.transient_internet(url): u = _urlopen_with_retry(url, timeout=120) self.addCleanup(u.close) self.assertEqual(u.fp.raw._sock.gettimeout(), 120) @@ -306,7 +307,7 @@ class TimeoutTest(unittest.TestCase): @skip_ftp_test_on_travis def test_ftp_basic(self): self.assertIsNone(socket.getdefaulttimeout()) - with support.transient_internet(self.FTP_HOST, timeout=None): + with socket_helper.transient_internet(self.FTP_HOST, timeout=None): u = _urlopen_with_retry(self.FTP_HOST) self.addCleanup(u.close) self.assertIsNone(u.fp.fp.raw._sock.gettimeout()) @@ -314,7 +315,7 @@ class TimeoutTest(unittest.TestCase): @skip_ftp_test_on_travis def test_ftp_default_timeout(self): self.assertIsNone(socket.getdefaulttimeout()) - with support.transient_internet(self.FTP_HOST): + with socket_helper.transient_internet(self.FTP_HOST): socket.setdefaulttimeout(60) try: u = _urlopen_with_retry(self.FTP_HOST) @@ -326,7 +327,7 @@ class TimeoutTest(unittest.TestCase): @skip_ftp_test_on_travis def test_ftp_no_timeout(self): self.assertIsNone(socket.getdefaulttimeout()) - with support.transient_internet(self.FTP_HOST): + with socket_helper.transient_internet(self.FTP_HOST): socket.setdefaulttimeout(60) try: u = _urlopen_with_retry(self.FTP_HOST, timeout=None) @@ -337,7 +338,7 @@ class TimeoutTest(unittest.TestCase): @skip_ftp_test_on_travis def test_ftp_timeout(self): - with support.transient_internet(self.FTP_HOST): + with socket_helper.transient_internet(self.FTP_HOST): u = _urlopen_with_retry(self.FTP_HOST, timeout=60) self.addCleanup(u.close) self.assertEqual(u.fp.fp.raw._sock.gettimeout(), 60) |