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

Method test_notes

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

Source from the content-addressed store, hash-verified

607 e.__setstate__(42)
608
609 def test_notes(self):
610 for e in [BaseException(1), Exception(2), ValueError(3)]:
611 with self.subTest(e=e):
612 self.assertNotHasAttr(e, '__notes__')
613 e.add_note("My Note")
614 self.assertEqual(e.__notes__, ["My Note"])
615
616 with self.assertRaises(TypeError):
617 e.add_note(42)
618 self.assertEqual(e.__notes__, ["My Note"])
619
620 e.add_note("Your Note")
621 self.assertEqual(e.__notes__, ["My Note", "Your Note"])
622
623 del e.__notes__
624 self.assertNotHasAttr(e, '__notes__')
625
626 e.add_note("Our Note")
627 self.assertEqual(e.__notes__, ["Our Note"])
628
629 e.__notes__ = 42
630 self.assertEqual(e.__notes__, 42)
631
632 with self.assertRaises(TypeError):
633 e.add_note("will not work")
634 self.assertEqual(e.__notes__, 42)
635
636 def testWithTraceback(self):
637 try:

Callers

nothing calls this directly

Calls 5

subTestMethod · 0.80
add_noteMethod · 0.80
assertNotHasAttrMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected