]> granicus.if.org Git - python/commitdiff
Skip testHostnameRes() if gethostbyname() raises an exception.
authorGuido van Rossum <guido@python.org>
Thu, 26 Dec 2002 16:55:15 +0000 (16:55 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 26 Dec 2002 16:55:15 +0000 (16:55 +0000)
Lib/test/test_socket.py

index ca3c4ff218190244a0accd3885b674abc895055c..11883a88575cf1e22cf46e8d6cfd646f87560d80 100644 (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