[Python-checkins] cpython (2.7): Issue #20939: Use www.example.com instead of www.python.org to avoid test
ned.deily
python-checkins at python.org
Thu Mar 27 07:34:28 CET 2014
http://hg.python.org/cpython/rev/426a7046cdb0
changeset: 89983:426a7046cdb0
branch: 2.7
parent: 89979:3f8b801e7e76
user: Ned Deily <nad at acm.org>
date: Wed Mar 26 23:25:02 2014 -0700
summary:
Issue #20939: Use www.example.com instead of www.python.org to avoid test
failures when ssl is not present.
files:
Lib/test/test_robotparser.py | 7 +++++++
Lib/test/test_urllib2net.py | 12 ++++++------
Lib/test/test_urllibnet.py | 24 ++++++++++++------------
Misc/NEWS | 5 +++--
4 files changed, 28 insertions(+), 20 deletions(-)
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
@@ -2,6 +2,12 @@
from test import test_support
from urllib2 import urlopen, HTTPError
+HAVE_HTTPS = True
+try:
+ from urllib2 import HTTPSHandler
+except ImportError:
+ HAVE_HTTPS = False
+
class RobotTestCase(unittest.TestCase):
def __init__(self, index, parser, url, good, agent):
unittest.TestCase.__init__(self)
@@ -269,6 +275,7 @@
self.skipTest('%s is unavailable' % url)
self.assertEqual(parser.can_fetch("*", robots_url), False)
+ @unittest.skipUnless(HAVE_HTTPS, 'need SSL support to download license')
def testPythonOrg(self):
test_support.requires('network')
with test_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
@@ -78,7 +78,7 @@
# underlying socket
# delve deep into response to fetch socket._socketobject
- response = _urlopen_with_retry("http://www.python.org/")
+ response = _urlopen_with_retry("http://www.example.com/")
abused_fileobject = response.fp
self.assertIs(abused_fileobject.__class__, socket._fileobject)
httpresponse = abused_fileobject._sock
@@ -163,7 +163,7 @@
"http://docs.python.org/2/glossary.html#glossary")
def test_fileno(self):
- req = urllib2.Request("http://www.python.org")
+ req = urllib2.Request("http://www.example.com")
opener = urllib2.build_opener()
res = opener.open(req)
try:
@@ -251,14 +251,14 @@
class TimeoutTest(unittest.TestCase):
def test_http_basic(self):
self.assertIsNone(socket.getdefaulttimeout())
- url = "http://www.python.org"
+ url = "http://www.example.com"
with test_support.transient_internet(url, timeout=None):
u = _urlopen_with_retry(url)
self.assertIsNone(u.fp._sock.fp._sock.gettimeout())
def test_http_default_timeout(self):
self.assertIsNone(socket.getdefaulttimeout())
- url = "http://www.python.org"
+ url = "http://www.example.com"
with test_support.transient_internet(url):
socket.setdefaulttimeout(60)
try:
@@ -269,7 +269,7 @@
def test_http_no_timeout(self):
self.assertIsNone(socket.getdefaulttimeout())
- url = "http://www.python.org"
+ url = "http://www.example.com"
with test_support.transient_internet(url):
socket.setdefaulttimeout(60)
try:
@@ -279,7 +279,7 @@
self.assertIsNone(u.fp._sock.fp._sock.gettimeout())
def test_http_timeout(self):
- url = "http://www.python.org"
+ url = "http://www.example.com"
with test_support.transient_internet(url):
u = _urlopen_with_retry(url, timeout=120)
self.assertEqual(u.fp._sock.fp._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
@@ -34,7 +34,7 @@
socket.setdefaulttimeout(None)
def testURLread(self):
- f = _open_with_retry(urllib.urlopen, "http://www.python.org/")
+ f = _open_with_retry(urllib.urlopen, "http://www.example.com/")
x = f.read()
class urlopenNetworkTests(unittest.TestCase):
@@ -46,7 +46,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.
@@ -57,7 +57,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 "
@@ -69,7 +69,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.assertIsInstance(open_url.readline(), basestring,
"readline did not return a string")
@@ -80,7 +80,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:
@@ -92,7 +92,7 @@
def test_geturl(self):
# Make sure same URL as opened is returned by geturl.
- URL = "https://www.python.org/"
+ URL = "http://www.example.com/"
open_url = self.urlopen(URL)
try:
gotten_url = open_url.geturl()
@@ -102,7 +102,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.FancyURLopener().open(URL)
try:
code = open_url.getcode()
@@ -114,7 +114,7 @@
@unittest.skipUnless(hasattr(os, 'fdopen'), 'os.fdopen not available')
def test_fileno(self):
# Make sure fd returned by fileno is valid.
- open_url = self.urlopen("http://www.python.org/")
+ open_url = self.urlopen("http://www.example.com/")
fd = open_url.fileno()
FILE = os.fdopen(fd)
try:
@@ -152,7 +152,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 = file(file_location)
@@ -165,7 +165,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/",
test_support.TESTFN)
self.assertEqual(file_location, test_support.TESTFN)
self.assertTrue(os.path.exists(file_location))
@@ -178,13 +178,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.assertIsInstance(header, mimetools.Message,
"header is not an instance of mimetools.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.getheader('Date')
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -324,8 +324,9 @@
- Issue #20605: Make test_socket getaddrinfo OS X segfault test more robust.
-- Issue #20939: Fix test_geturl failure in test_urllibnet due to
- new redirect of http://www.python.org/ to https://www.python.org.
+- Issue #20939: Avoid various network test failures due to new
+ redirect of http://www.python.org/ to https://www.python.org:
+ use http://www.example.com instead.
Documentation
-------------
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list