From: Brett Cannon Date: Fri, 11 Mar 2005 00:04:17 +0000 (+0000) Subject: Fix test for socket.getfqdn() to also include the name returned by X-Git-Tag: v2.5a0~1934 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=01668a1ab93baacd3c68f8b0b3b0ca6d43f0f444;p=python Fix test for socket.getfqdn() to also include the name returned by socket.gethostname() in the check for a valid return. Also clarified docs (official and docstring) that the value from gethostname() is returned if gethostbyaddr() doesn't do the job. --- diff --git a/Doc/lib/libsocket.tex b/Doc/lib/libsocket.tex index db0b76762f..1f5bcaa615 100644 --- a/Doc/lib/libsocket.tex +++ b/Doc/lib/libsocket.tex @@ -202,8 +202,8 @@ If \var{name} is omitted or empty, it is interpreted as the local host. To find the fully qualified name, the hostname returned by \function{gethostbyaddr()} is checked, then aliases for the host, if available. The first name which includes a period is selected. In -case no fully qualified domain name is available, the hostname is -returned. +case no fully qualified domain name is available, the hostname as +returned by \function{gethostname()} is returned. \versionadded{2.0} \end{funcdesc} diff --git a/Lib/socket.py b/Lib/socket.py index f96a146837..ee2457fa0c 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -102,7 +102,7 @@ def getfqdn(name=''): First the hostname returned by gethostbyaddr() is checked, then possibly existing aliases. In case no FQDN is available, hostname - is returned. + from gethostname() is returned. """ name = name.strip() if not name or name == '0.0.0.0': diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index e6cdb8b2cc..bf2ecae507 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -267,7 +267,7 @@ class GeneralModuleTests(unittest.TestCase): except socket.error: # Probably a similar problem as above; skip this test return - all_host_names = [hname] + aliases + all_host_names = [hostname, hname] + aliases fqhn = socket.getfqdn() if not fqhn in all_host_names: self.fail("Error testing host resolution mechanisms.")