mirror of
https://github.com/python/cpython.git
synced 2025-09-18 14:40:43 +00:00
socket.gethostbyname(socket.gethostname()) can fail when host name resolution is not set up correctly; do not fail test_socket if this is the case.
This commit is contained in:
parent
cd6bb26fa7
commit
89197fe93c
2 changed files with 8 additions and 1 deletions
|
@ -544,7 +544,11 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
# XXX(nnorwitz): http://tinyurl.com/os5jz seems to indicate
|
# XXX(nnorwitz): http://tinyurl.com/os5jz seems to indicate
|
||||||
# it reasonable to get the host's addr in addition to 0.0.0.0.
|
# it reasonable to get the host's addr in addition to 0.0.0.0.
|
||||||
# At least for eCos. This is required for the S/390 to pass.
|
# At least for eCos. This is required for the S/390 to pass.
|
||||||
|
try:
|
||||||
my_ip_addr = socket.gethostbyname(socket.gethostname())
|
my_ip_addr = socket.gethostbyname(socket.gethostname())
|
||||||
|
except socket.error:
|
||||||
|
# Probably name lookup wasn't set up right; skip this test
|
||||||
|
return
|
||||||
self.assertIn(name[0], ("0.0.0.0", my_ip_addr), '%s invalid' % name[0])
|
self.assertIn(name[0], ("0.0.0.0", my_ip_addr), '%s invalid' % name[0])
|
||||||
self.assertEqual(name[1], port)
|
self.assertEqual(name[1], port)
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,9 @@ C-API
|
||||||
Tests
|
Tests
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
- Do not fail test_socket when the IP address of the local hostname
|
||||||
|
cannot be looked up.
|
||||||
|
|
||||||
- Issue #8886: Use context managers throughout test_zipfile. Patch by
|
- Issue #8886: Use context managers throughout test_zipfile. Patch by
|
||||||
Eric Carstensen.
|
Eric Carstensen.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue