Skip to content

Commit

Permalink
testGetServByName shouldn't check for getservbyname - the socket module
Browse files Browse the repository at this point in the history
should always have it.
  • Loading branch information
Skip Montanaro committed Aug 2, 2002
1 parent 940e970 commit f443330
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions Lib/test/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,24 +259,23 @@ def testNtoH(self):

def testGetServByName(self):
"""Testing getservbyname()."""
if hasattr(socket, 'getservbyname'):
# 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
# 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."""
Expand Down

0 comments on commit f443330

Please sign in to comment.