Fix indentation error in testGetServByName and rewrite loop to avoid clumsy
sentinel variable
This commit is contained in:
parent
029dba5a40
commit
05eb40128e
|
@ -273,21 +273,18 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
def testGetServByName(self):
|
def testGetServByName(self):
|
||||||
# Testing getservbyname()
|
# Testing getservbyname()
|
||||||
# try a few protocols - not everyone has telnet enabled
|
# try a few protocols - not everyone has telnet enabled
|
||||||
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
|
|
||||||
break
|
break
|
||||||
except socket.error:
|
except socket.error:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
socket.getservbyname(proto, 'udp')
|
socket.getservbyname(proto, 'udp')
|
||||||
found = 1
|
|
||||||
break
|
break
|
||||||
except socket.error:
|
except socket.error:
|
||||||
pass
|
pass
|
||||||
if not found:
|
else:
|
||||||
raise socket.error
|
raise socket.error
|
||||||
|
|
||||||
def testDefaultTimeout(self):
|
def testDefaultTimeout(self):
|
||||||
|
|
Loading…
Reference in New Issue