MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_cause

Method test_cause

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

Source from the content-addressed store, hash-verified

3679 self.assertEqual(str(exc_obj), str(exc))
3680
3681 def test_cause(self):
3682 try:
3683 try:
3684 1/0
3685 finally:
3686 exc = sys.exception()
3687 exc_context = traceback.TracebackException.from_exception(exc)
3688 cause = Exception("cause")
3689 raise Exception("uh oh") from cause
3690 except Exception as e:
3691 exc_obj = e
3692 exc = traceback.TracebackException.from_exception(e)
3693 expected_stack = traceback.StackSummary.extract(
3694 traceback.walk_tb(e.__traceback__))
3695 exc_cause = traceback.TracebackException(Exception, cause, None)
3696 self.assertEqual(exc_cause, exc.__cause__)
3697 self.assertEqual(exc_context, exc.__context__)
3698 self.assertEqual(True, exc.__suppress_context__)
3699 self.assertEqual(expected_stack, exc.stack)
3700 with self.assertWarns(DeprecationWarning):
3701 self.assertEqual(type(exc_obj), exc.exc_type)
3702 self.assertEqual(type(exc_obj).__name__, exc.exc_type_str)
3703 self.assertEqual(str(exc_obj), str(exc))
3704
3705 def test_context(self):
3706 try:

Callers

nothing calls this directly

Calls 6

strFunction · 0.85
from_exceptionMethod · 0.80
assertWarnsMethod · 0.80
exceptionMethod · 0.45
extractMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected