try/except/finally is a 2.5 feature

This commit is contained in:
Ryan Williams
2010-02-26 14:48:46 -08:00
parent 9ea51df206
commit a01e6cdcd9

View File

@@ -40,12 +40,13 @@ class TestSocketErrors(unittest.TestCase):
cs, addr = server.accept()
cs.settimeout(1)
try:
cs.recv(1024)
self.fail("Should have timed out")
except socket.timeout, ex:
assert hasattr(ex, 'args')
assert len(ex.args) == 1
assert ex.args[0] == 'timed out'
try:
cs.recv(1024)
self.fail("Should have timed out")
except socket.timeout, ex:
assert hasattr(ex, 'args')
assert len(ex.args) == 1
assert ex.args[0] == 'timed out'
finally:
s.close()
cs.close()