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, addr = server.accept()
cs.settimeout(1) cs.settimeout(1)
try: try:
cs.recv(1024) try:
self.fail("Should have timed out") cs.recv(1024)
except socket.timeout, ex: self.fail("Should have timed out")
assert hasattr(ex, 'args') except socket.timeout, ex:
assert len(ex.args) == 1 assert hasattr(ex, 'args')
assert ex.args[0] == 'timed out' assert len(ex.args) == 1
assert ex.args[0] == 'timed out'
finally: finally:
s.close() s.close()
cs.close() cs.close()