summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNadeem Vawda <nadeem.vawda@gmail.com>2012-01-25 06:02:05 (GMT)
committerNadeem Vawda <nadeem.vawda@gmail.com>2012-01-25 06:02:05 (GMT)
commit61baebd0e125ba281c2b1f40c210ce286e2e4f0d (patch)
tree6a153638ef9e6f4377fd892a02c2b8e46fbc08a3
parenta58c01ba48a4426db45dff71324be6c617efa724 (diff)
downloadcpython-61baebd0e125ba281c2b1f40c210ce286e2e4f0d.zip
cpython-61baebd0e125ba281c2b1f40c210ce286e2e4f0d.tar.gz
cpython-61baebd0e125ba281c2b1f40c210ce286e2e4f0d.tar.bz2
Issue #12804: Fix test failures on systems without internet access.
-rw-r--r--Lib/test/test_socket.py6
-rw-r--r--Lib/test/test_urllib2net.py13
-rw-r--r--Misc/NEWS3
3 files changed, 16 insertions, 6 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index d277e36..ede1038 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -1168,6 +1168,12 @@ class GeneralModuleTests(unittest.TestCase):
@unittest.skipUnless(support.is_resource_enabled('network'),
'network is not enabled')
def test_idna(self):
+ # Check for internet access before running test (issue #12804).
+ try:
+ socket.gethostbyname('python.org')
+ except socket.gaierror as e:
+ if e.errno == socket.EAI_NODATA:
+ self.skipTest('internet access required for this test')
# these should all be successful
socket.gethostbyname('испытание.python.org')
socket.gethostbyname_ex('испытание.python.org')
diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py
index 5fcb4cb..fc5527e 100644
--- a/Lib/test/test_urllib2net.py
+++ b/Lib/test/test_urllib2net.py
@@ -83,12 +83,13 @@ class CloseSocketTest(unittest.TestCase):
def test_close(self):
# calling .close() on urllib2's response objects should close the
# underlying socket
-
- response = _urlopen_with_retry("http://www.python.org/")
- sock = response.fp
- self.assertTrue(not sock.closed)
- response.close()
- self.assertTrue(sock.closed)
+ url = "http://www.python.org/"
+ with support.transient_internet(url):
+ response = _urlopen_with_retry(url)
+ sock = response.fp
+ self.assertTrue(not sock.closed)
+ response.close()
+ self.assertTrue(sock.closed)
class OtherNetworkTests(unittest.TestCase):
def setUp(self):
diff --git a/Misc/NEWS b/Misc/NEWS
index 9c34ac8..f6b1f0d 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -461,6 +461,9 @@ Core and Builtins
Library
-------
+- Issue #12804: Fix test_socket and test_urllib2net failures when running tests
+ on a system without internet access.
+
- Issue #13772: In os.symlink() under Windows, do not try to guess the link
target's type (file or directory). The detection was buggy and made the
call non-atomic (therefore prone to race conditions).