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

Method testWithTraceback

Lib/test/test_exceptions.py:636–655  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

634 self.assertEqual(e.__notes__, 42)
635
636 def testWithTraceback(self):
637 try:
638 raise IndexError(4)
639 except Exception as e:
640 tb = e.__traceback__
641
642 e = BaseException().with_traceback(tb)
643 self.assertIsInstance(e, BaseException)
644 self.assertEqual(e.__traceback__, tb)
645
646 e = IndexError(5).with_traceback(tb)
647 self.assertIsInstance(e, IndexError)
648 self.assertEqual(e.__traceback__, tb)
649
650 class MyException(Exception):
651 pass
652
653 e = MyException().with_traceback(tb)
654 self.assertIsInstance(e, MyException)
655 self.assertEqual(e.__traceback__, tb)
656
657 def testInvalidTraceback(self):
658 try:

Callers

nothing calls this directly

Calls 4

with_tracebackMethod · 0.80
assertIsInstanceMethod · 0.80
MyExceptionClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected