| LEFT | RIGHT |
| 1 # Python test set -- part 5, built-in exceptions | 1 # Python test set -- part 5, built-in exceptions |
| 2 | 2 |
| 3 import os | 3 import os |
| 4 import sys | 4 import sys |
| 5 import unittest | 5 import unittest |
| 6 import pickle | 6 import pickle |
| 7 import weakref | 7 import weakref |
| 8 import errno | 8 import errno |
| 9 | 9 |
| 10 from test.support import (TESTFN, unlink, run_unittest, captured_output, | 10 from test.support import (TESTFN, unlink, run_unittest, captured_output, |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 self.assertIsNone(e.__context__) | 394 self.assertIsNone(e.__context__) |
| 395 self.assertIs(e.__cause__, Ellipsis) | 395 self.assertIs(e.__cause__, Ellipsis) |
| 396 | 396 |
| 397 class MyException(EnvironmentError): | 397 class MyException(EnvironmentError): |
| 398 pass | 398 pass |
| 399 | 399 |
| 400 e = MyException() | 400 e = MyException() |
| 401 self.assertIsNone(e.__context__) | 401 self.assertIsNone(e.__context__) |
| 402 self.assertIs(e.__cause__, Ellipsis) | 402 self.assertIs(e.__cause__, Ellipsis) |
| 403 | 403 |
| 404 def testChainingDescriptors(self): |
| 404 try: | 405 try: |
| 405 raise Exception() | 406 raise Exception() |
| 406 except Exception as exc: | 407 except Exception as exc: |
| 407 e = exc | 408 e = exc |
| 408 | 409 |
| 409 self.assertIsNone(e.__context__) | 410 self.assertIsNone(e.__context__) |
| 410 self.assertIs(e.__cause__, Ellipsis) | 411 self.assertIs(e.__cause__, Ellipsis) |
| 411 | 412 |
| 412 e.__context__ = NameError() | 413 e.__context__ = NameError() |
| 413 e.__cause__ = None | 414 e.__cause__ = None |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 with self.assertRaises(OSError) as cm: | 900 with self.assertRaises(OSError) as cm: |
| 900 os.listdir(__file__) | 901 os.listdir(__file__) |
| 901 self.assertEqual(cm.exception.errno, errno.ENOTDIR, cm.exception) | 902 self.assertEqual(cm.exception.errno, errno.ENOTDIR, cm.exception) |
| 902 | 903 |
| 903 | 904 |
| 904 def test_main(): | 905 def test_main(): |
| 905 run_unittest(ExceptionTests) | 906 run_unittest(ExceptionTests) |
| 906 | 907 |
| 907 if __name__ == '__main__': | 908 if __name__ == '__main__': |
| 908 unittest.main() | 909 unittest.main() |
| LEFT | RIGHT |