Commit 61baebd0 authored by Nadeem Vawda's avatar Nadeem Vawda

Issue #12804: Fix test failures on systems without internet access.

parent a58c01ba
...@@ -1168,6 +1168,12 @@ class GeneralModuleTests(unittest.TestCase): ...@@ -1168,6 +1168,12 @@ class GeneralModuleTests(unittest.TestCase):
@unittest.skipUnless(support.is_resource_enabled('network'), @unittest.skipUnless(support.is_resource_enabled('network'),
'network is not enabled') 'network is not enabled')
def test_idna(self): 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 # these should all be successful
socket.gethostbyname('испытание.python.org') socket.gethostbyname('испытание.python.org')
socket.gethostbyname_ex('испытание.python.org') socket.gethostbyname_ex('испытание.python.org')
......
...@@ -83,12 +83,13 @@ class CloseSocketTest(unittest.TestCase): ...@@ -83,12 +83,13 @@ class CloseSocketTest(unittest.TestCase):
def test_close(self): def test_close(self):
# calling .close() on urllib2's response objects should close the # calling .close() on urllib2's response objects should close the
# underlying socket # underlying socket
url = "http://www.python.org/"
response = _urlopen_with_retry("http://www.python.org/") with support.transient_internet(url):
sock = response.fp response = _urlopen_with_retry(url)
self.assertTrue(not sock.closed) sock = response.fp
response.close() self.assertTrue(not sock.closed)
self.assertTrue(sock.closed) response.close()
self.assertTrue(sock.closed)
class OtherNetworkTests(unittest.TestCase): class OtherNetworkTests(unittest.TestCase):
def setUp(self): def setUp(self):
......
...@@ -461,6 +461,9 @@ Core and Builtins ...@@ -461,6 +461,9 @@ Core and Builtins
Library 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 - 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 target's type (file or directory). The detection was buggy and made the
call non-atomic (therefore prone to race conditions). call non-atomic (therefore prone to race conditions).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment