OLD | NEW |
| (Empty) |
1 # -*- test-case-name: twisted.test.test_assertions -*- | |
2 # Copyright (c) 2001-2004 Twisted Matrix Laboratories. | |
3 # See LICENSE for details. | |
4 | |
5 from twisted.trial import unittest | |
6 from twisted.python import failure | |
7 | |
8 class Assertions(unittest.TestCase): | |
9 def testExceptions(self): | |
10 exc = self.assertRaises(ZeroDivisionError, lambda: 1/0) | |
11 assert isinstance(exc, ZeroDivisionError), "ZeroDivisionError instance n
ot returned" | |
12 | |
13 for func in [lambda: 1/0, lambda: None]: | |
14 try: | |
15 self.assertRaises(ValueError, func) | |
16 except unittest.FailTest: | |
17 # Success! | |
18 pass | |
19 except: | |
20 raise unittest.FailTest("FailTest not raised", failure.Failure()
.getTraceback()) | |
21 else: | |
22 raise unittest.FailTest("FailTest not raised") | |
OLD | NEW |