MCPcopy Index your code
hub / github.com/python/cpython / test_from_exception

Method test_from_exception

Lib/test/test_traceback.py:3578–3601  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls 6

strFunction · 0.85
from_exceptionMethod · 0.80
assertWarnsMethod · 0.80
fooFunction · 0.70
extractMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected