# HG changeset patch # Parent e06f51743631e8dfce8e5aee11fe5c1f1fd2bd9d Issue #20939: Use example.com instead of www.python.org to avoid ssl redirects. diff --git a/Lib/test/test_robotparser.py b/Lib/test/test_robotparser.py --- a/Lib/test/test_robotparser.py +++ b/Lib/test/test_robotparser.py @@ -245,6 +245,7 @@ self.skipTest('%s is unavailable' % url) self.assertEqual(parser.can_fetch("*", url+"/robots.txt"), False) + @unittest.skip('does not handle the gzip encoding delivered by pydotorg') def testPythonOrg(self): support.requires('network') with support.transient_internet('www.python.org'): diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py --- a/Lib/test/test_urllib2net.py +++ b/Lib/test/test_urllib2net.py @@ -83,7 +83,7 @@ # calling .close() on urllib2's response objects should close the # underlying socket - response = _urlopen_with_retry("http://www.python.org/") + response = _urlopen_with_retry("http://www.example.com/") sock = response.fp self.assertTrue(not sock.closed) response.close() @@ -153,12 +153,12 @@ ## self._test_urls(urls, self._extra_handlers()+[bauth, dauth]) def test_urlwithfrag(self): - urlwith_frag = "http://docs.python.org/glossary.html#glossary" + urlwith_frag = "http://docs.python.org/2/glossary.html#glossary" with support.transient_internet(urlwith_frag): req = urllib.request.Request(urlwith_frag) res = urllib.request.urlopen(req) self.assertEqual(res.geturl(), - "http://docs.python.org/glossary.html#glossary") + "http://docs.python.org/2/glossary.html#glossary") def test_custom_headers(self): url = "http://www.example.com" @@ -230,14 +230,14 @@ class TimeoutTest(unittest.TestCase): def test_http_basic(self): self.assertTrue(socket.getdefaulttimeout() is None) - url = "http://www.python.org" + url = "http://www.example.com" with support.transient_internet(url, timeout=None): u = _urlopen_with_retry(url) self.assertTrue(u.fp.raw._sock.gettimeout() is None) def test_http_default_timeout(self): self.assertTrue(socket.getdefaulttimeout() is None) - url = "http://www.python.org" + url = "http://www.example.com" with support.transient_internet(url): socket.setdefaulttimeout(60) try: @@ -248,7 +248,7 @@ def test_http_no_timeout(self): self.assertTrue(socket.getdefaulttimeout() is None) - url = "http://www.python.org" + url = "http://www.example.com" with support.transient_internet(url): socket.setdefaulttimeout(60) try: @@ -258,7 +258,7 @@ self.assertTrue(u.fp.raw._sock.gettimeout() is None) def test_http_timeout(self): - url = "http://www.python.org" + url = "http://www.example.com" with support.transient_internet(url): u = _urlopen_with_retry(url, timeout=120) self.assertEqual(u.fp.raw._sock.gettimeout(), 120) diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py --- a/Lib/test/test_urllibnet.py +++ b/Lib/test/test_urllibnet.py @@ -23,7 +23,7 @@ def testURLread(self): with support.transient_internet("www.python.org"): - f = urllib.request.urlopen("http://www.python.org/") + f = urllib.request.urlopen("http://www.example.com/") x = f.read() class urlopenNetworkTests(unittest.TestCase): @@ -35,7 +35,7 @@ for transparent redirection have been written. setUp is not used for always constructing a connection to - http://www.python.org/ since there a few tests that don't use that address + http://www.example.com/ since there a few tests that don't use that address and making a connection is expensive enough to warrant minimizing unneeded connections. @@ -48,7 +48,7 @@ def test_basic(self): # Simple test expected to pass. - open_url = self.urlopen("http://www.python.org/") + open_url = self.urlopen("http://www.example.com/") for attr in ("read", "readline", "readlines", "fileno", "close", "info", "geturl"): self.assertTrue(hasattr(open_url, attr), "object returned from " @@ -60,7 +60,7 @@ def test_readlines(self): # Test both readline and readlines. - open_url = self.urlopen("http://www.python.org/") + open_url = self.urlopen("http://www.example.com/") try: self.assertTrue(isinstance(open_url.readline(), bytes), "readline did not return bytes") @@ -71,7 +71,7 @@ def test_info(self): # Test 'info'. - open_url = self.urlopen("http://www.python.org/") + open_url = self.urlopen("http://www.example.com/") try: info_obj = open_url.info() finally: @@ -83,7 +83,7 @@ def test_geturl(self): # Make sure same URL as opened is returned by geturl. - URL = "http://www.python.org/" + URL = "http://www.example.com/" open_url = self.urlopen(URL) try: gotten_url = open_url.geturl() @@ -93,7 +93,7 @@ def test_getcode(self): # test getcode() with the fancy opener to get 404 error codes - URL = "http://www.python.org/XXXinvalidXXX" + URL = "http://www.example.com/XXXinvalidXXX" open_url = urllib.request.FancyURLopener().open(URL) try: code = open_url.getcode() @@ -107,7 +107,7 @@ # test can't pass on Windows. return # Make sure fd returned by fileno is valid. - open_url = self.urlopen("http://www.python.org/", timeout=None) + open_url = self.urlopen("http://www.example.com/", timeout=None) fd = open_url.fileno() FILE = os.fdopen(fd, 'rb') try: @@ -140,7 +140,7 @@ def test_basic(self): # Test basic functionality. - file_location,info = self.urlretrieve("http://www.python.org/") + file_location,info = self.urlretrieve("http://www.example.com/") self.assertTrue(os.path.exists(file_location), "file location returned by" " urlretrieve is not a valid path") FILE = open(file_location, 'rb') @@ -153,7 +153,7 @@ def test_specified_path(self): # Make sure that specifying the location of the file to write to works. - file_location,info = self.urlretrieve("http://www.python.org/", + file_location,info = self.urlretrieve("http://www.example.com/", support.TESTFN) self.assertEqual(file_location, support.TESTFN) self.assertTrue(os.path.exists(file_location)) @@ -166,13 +166,13 @@ def test_header(self): # Make sure header returned as 2nd value from urlretrieve is good. - file_location, header = self.urlretrieve("http://www.python.org/") + file_location, header = self.urlretrieve("http://www.example.com/") os.unlink(file_location) self.assertTrue(isinstance(header, email.message.Message), "header is not an instance of email.message.Message") def test_data_header(self): - logo = "http://python.org/static/community_logos/python-logo-master-v3-TM.png" + logo = "http://www.example.com/" file_location, fileheaders = self.urlretrieve(logo) os.unlink(file_location) datevalue = fileheaders.get('Date')