Kaydet (Commit) 01668a1a authored tarafından Brett Cannon's avatar Brett Cannon

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.
üst 94d6201e
...@@ -202,8 +202,8 @@ If \var{name} is omitted or empty, it is interpreted as the local ...@@ -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 host. To find the fully qualified name, the hostname returned by
\function{gethostbyaddr()} is checked, then aliases for the host, if \function{gethostbyaddr()} is checked, then aliases for the host, if
available. The first name which includes a period is selected. In available. The first name which includes a period is selected. In
case no fully qualified domain name is available, the hostname is case no fully qualified domain name is available, the hostname as
returned. returned by \function{gethostname()} is returned.
\versionadded{2.0} \versionadded{2.0}
\end{funcdesc} \end{funcdesc}
......
...@@ -102,7 +102,7 @@ def getfqdn(name=''): ...@@ -102,7 +102,7 @@ def getfqdn(name=''):
First the hostname returned by gethostbyaddr() is checked, then First the hostname returned by gethostbyaddr() is checked, then
possibly existing aliases. In case no FQDN is available, hostname possibly existing aliases. In case no FQDN is available, hostname
is returned. from gethostname() is returned.
""" """
name = name.strip() name = name.strip()
if not name or name == '0.0.0.0': if not name or name == '0.0.0.0':
......
...@@ -267,7 +267,7 @@ class GeneralModuleTests(unittest.TestCase): ...@@ -267,7 +267,7 @@ class GeneralModuleTests(unittest.TestCase):
except socket.error: except socket.error:
# Probably a similar problem as above; skip this test # Probably a similar problem as above; skip this test
return return
all_host_names = [hname] + aliases all_host_names = [hostname, hname] + aliases
fqhn = socket.getfqdn() fqhn = socket.getfqdn()
if not fqhn in all_host_names: if not fqhn in all_host_names:
self.fail("Error testing host resolution mechanisms.") self.fail("Error testing host resolution mechanisms.")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment