diff options
author | Skip Montanaro <skip@pobox.com> | 2002-08-02 02:19:46 (GMT) |
---|---|---|
committer | Skip Montanaro <skip@pobox.com> | 2002-08-02 02:19:46 (GMT) |
commit | d3c884d4ea6f9e3bf68100734bdf7040db9397cb (patch) | |
tree | dc3eb4adc68852b4c11c7a746db356dfcc587dde | |
parent | ea0c3828c00de81c953e147e085d4d2b4b906850 (diff) | |
download | cpython-d3c884d4ea6f9e3bf68100734bdf7040db9397cb.zip cpython-d3c884d4ea6f9e3bf68100734bdf7040db9397cb.tar.gz cpython-d3c884d4ea6f9e3bf68100734bdf7040db9397cb.tar.bz2 |
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
-rw-r--r-- | Lib/test/test_socket.py | 22 |
1 files 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.""" |