(self)
| 3576 | self.do_test_smoke(MyException('bad things happened'), expected) |
| 3577 | |
| 3578 | def test_from_exception(self): |
| 3579 | # Check all the parameters are accepted. |
| 3580 | def foo(): |
| 3581 | 1/0 |
| 3582 | try: |
| 3583 | foo() |
| 3584 | except Exception as e: |
| 3585 | exc_obj = e |
| 3586 | tb = e.__traceback__ |
| 3587 | self.expected_stack = traceback.StackSummary.extract( |
| 3588 | traceback.walk_tb(tb), limit=1, lookup_lines=False, |
| 3589 | capture_locals=True) |
| 3590 | self.exc = traceback.TracebackException.from_exception( |
| 3591 | e, limit=1, lookup_lines=False, capture_locals=True) |
| 3592 | expected_stack = self.expected_stack |
| 3593 | exc = self.exc |
| 3594 | self.assertEqual(None, exc.__cause__) |
| 3595 | self.assertEqual(None, exc.__context__) |
| 3596 | self.assertEqual(False, exc.__suppress_context__) |
| 3597 | self.assertEqual(expected_stack, exc.stack) |
| 3598 | with self.assertWarns(DeprecationWarning): |
| 3599 | self.assertEqual(type(exc_obj), exc.exc_type) |
| 3600 | self.assertEqual(type(exc_obj).__name__, exc.exc_type_str) |
| 3601 | self.assertEqual(str(exc_obj), str(exc)) |
| 3602 | |
| 3603 | def test_cause(self): |
| 3604 | try: |
nothing calls this directly
no test coverage detected