mirror of
https://github.com/python/cpython.git
synced 2025-09-14 20:56:06 +00:00
testGetServByName shouldn't check for getservbyname - the socket module
should always have it.
This commit is contained in:
parent
940e970f6e
commit
f4433303a8
1 changed files with 17 additions and 18 deletions
|
@ -259,24 +259,23 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
|
|
||||||
def testGetServByName(self):
|
def testGetServByName(self):
|
||||||
"""Testing getservbyname()."""
|
"""Testing getservbyname()."""
|
||||||
if hasattr(socket, 'getservbyname'):
|
# try a few protocols - not everyone has telnet enabled
|
||||||
# try a few protocols - not everyone has telnet enabled
|
found = 0
|
||||||
found = 0
|
for proto in ("telnet", "ssh", "www", "ftp"):
|
||||||
for proto in ("telnet", "ssh", "www", "ftp"):
|
try:
|
||||||
try:
|
socket.getservbyname(proto, 'tcp')
|
||||||
socket.getservbyname(proto, 'tcp')
|
found = 1
|
||||||
found = 1
|
break
|
||||||
break
|
except socket.error:
|
||||||
except socket.error:
|
pass
|
||||||
pass
|
try:
|
||||||
try:
|
socket.getservbyname(proto, 'udp')
|
||||||
socket.getservbyname(proto, 'udp')
|
found = 1
|
||||||
found = 1
|
break
|
||||||
break
|
except socket.error:
|
||||||
except socket.error:
|
pass
|
||||||
pass
|
if not found:
|
||||||
if not found:
|
raise socket.error
|
||||||
raise socket.error
|
|
||||||
|
|
||||||
def testDefaultTimeout(self):
|
def testDefaultTimeout(self):
|
||||||
"""Testing default timeout."""
|
"""Testing default timeout."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue