From 71e02946ff022adfa391af864638675788e1f044 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 26 Dec 2002 16:55:15 +0000 Subject: [PATCH] Skip testHostnameRes() if gethostbyname() raises an exception. --- Lib/test/test_socket.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index ca3c4ff2181..11883a88575 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