From: Guido van Rossum Date: Thu, 26 Dec 2002 16:55:15 +0000 (+0000) Subject: Skip testHostnameRes() if gethostbyname() raises an exception. X-Git-Tag: v2.3c1~2875 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=71e02946ff022adfa391af864638675788e1f044;p=python Skip testHostnameRes() if gethostbyname() raises an exception. --- diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index ca3c4ff218..11883a8857 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -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