mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Skip testHostnameRes() if gethostbyname() raises an exception.
This commit is contained in:
parent
490602d629
commit
71e02946ff
1 changed files with 5 additions and 1 deletions
|
@ -220,7 +220,11 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
def testHostnameRes(self):
|
def testHostnameRes(self):
|
||||||
# Testing hostname resolution mechanisms
|
# Testing hostname resolution mechanisms
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
ip = socket.gethostbyname(hostname)
|
try:
|
||||||
|
ip = socket.gethostbyname(hostname)
|
||||||
|
except socket.error:
|
||||||
|
# Probably name lookup wasn't set up right; skip this test
|
||||||
|
return
|
||||||
self.assert_(ip.find('.') >= 0, "Error resolving host to ip.")
|
self.assert_(ip.find('.') >= 0, "Error resolving host to ip.")
|
||||||
hname, aliases, ipaddrs = socket.gethostbyaddr(ip)
|
hname, aliases, ipaddrs = socket.gethostbyaddr(ip)
|
||||||
all_host_names = [hname] + aliases
|
all_host_names = [hname] + aliases
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue