summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_socket.py
diff options
context:
space:
mode:
authorAndrew MacIntyre <andymac@bullseye.apana.org.au>2004-07-12 12:10:30 (GMT)
committerAndrew MacIntyre <andymac@bullseye.apana.org.au>2004-07-12 12:10:30 (GMT)
commit18bf43c4a4ca170f175207e3875788709b296248 (patch)
tree6b67a1e52532f681b6751f028d480beea29c537a /Lib/test/test_socket.py
parentfd4984d1fcb208150fec3aa69286e269f3f10090 (diff)
downloadcpython-18bf43c4a4ca170f175207e3875788709b296248.zip
cpython-18bf43c4a4ca170f175207e3875788709b296248.tar.gz
cpython-18bf43c4a4ca170f175207e3875788709b296248.tar.bz2
FreeBSD's services file contains an additional echo service entry, with
a non-standard protocol and on a lower port than the tcp/udp entries, which breaks the assumption that there will only be one service by a given name on a given port when no protocol is specified. Previous versions of this code have had other problems as a result of different service definitions amongst common platforms. As this platform has an extra, unexpected, service entry, I've special cased the platform rather than re-order the list of services checked to highlight the pitfall.
Diffstat (limited to 'Lib/test/test_socket.py')
-rw-r--r--Lib/test/test_socket.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 180d965..adeca56 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -289,7 +289,13 @@ class GeneralModuleTests(unittest.TestCase):
# Find one service that exists, then check all the related interfaces.
# I've ordered this by protocols that have both a tcp and udp
# protocol, at least for modern Linuxes.
- for service in ('echo', 'daytime', 'domain'):
+ if sys.platform in ('freebsd4', 'freebsd5'):
+ # avoid the 'echo' service on this platform, as there is an
+ # assumption breaking non-standard port/protocol entry
+ services = ('daytime', 'qotd', 'domain')
+ else:
+ services = ('echo', 'daytime', 'domain')
+ for service in services:
try:
port = socket.getservbyname(service, 'tcp')
break