Skip testHostnameRes() if gethostbyname() raises an exception.

This commit is contained in:
Guido van Rossum 2002-12-26 16:55:15 +00:00
parent 490602d629
commit 71e02946ff
1 changed files with 5 additions and 1 deletions

View File

@ -220,7 +220,11 @@ class GeneralModuleTests(unittest.TestCase):
def testHostnameRes(self):
# Testing hostname resolution mechanisms
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.")
hname, aliases, ipaddrs = socket.gethostbyaddr(ip)
all_host_names = [hname] + aliases