From d3c884d4ea6f9e3bf68100734bdf7040db9397cb Mon Sep 17 00:00:00 2001 From: Skip Montanaro Date: Fri, 2 Aug 2002 02:19:46 +0000 Subject: modify testGetServByName so it tries a few different protocols. In this day and age of rampant computer breakins I imagine there are plenty of systems with telnet disabled. Successful check of at least one getservbyname() call is required for success --- Lib/test/test_socket.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index e811348..b4bb293 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -260,11 +260,23 @@ class GeneralModuleTests(unittest.TestCase): def testGetServByName(self): """Testing getservbyname().""" if hasattr(socket, 'getservbyname'): - socket.getservbyname('telnet', 'tcp') - try: - socket.getservbyname('telnet', 'udp') - except socket.error: - pass + # try a few protocols - not everyone has telnet enabled + found = 0 + for proto in ("telnet", "ssh", "www", "ftp"): + try: + socket.getservbyname(proto, 'tcp') + found = 1 + break + except socket.error: + pass + try: + socket.getservbyname(proto, 'udp') + found = 1 + break + except socket.error: + pass + if not found: + raise socket.error def testDefaultTimeout(self): """Testing default timeout.""" -- cgit v0.12