summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1997-01-13 19:35:39 +0000
committerBarry Warsaw <barry@python.org>1997-01-13 19:35:39 +0000
commitdbfb8d46260e29d2ca3068174aeeadced057b5fe (patch)
tree562e5f7ed48d557d8b6331c8f67f45419bdb5c32 /Lib/test
parentd08735a54b8aa249482d028a6d998bd9a08ad957 (diff)
downloadcpython-git-dbfb8d46260e29d2ca3068174aeeadced057b5fe.tar.gz
Rewrite the `hostname mismatch' test as per GvR suggestion.
Don't assume gethostbyaddr()'s primary hostname is the same as gethostname(), or even that gethostname() can be found in the list of hosts returned by gethostbyaddr(). We do test for at least one FQDN in gethostbyaddr().
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_socket.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 2b3c504984..f7b62a9bbc 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -12,6 +12,7 @@ from test_support import verbose
import socket
import os
import time
+import string
def missing_ok(str):
try:
@@ -67,14 +68,19 @@ for optional in ("AF_UNIX",
hostname = socket.gethostname()
ip = socket.gethostbyname(hostname)
hname, aliases, ipaddrs = socket.gethostbyaddr(ip)
+all_host_names = [hname] + aliases
if verbose:
print hostname
print ip
print hname, aliases, ipaddrs
+ print all_host_names
-if hostname <> hname:
- print 'hostname mismatch'
+for name in all_host_names:
+ if string.find(name, '.'):
+ break
+else:
+ print 'FQDN not found'
print socket.getservbyname('telnet', 'tcp')
try: