Datasets:
File size: 1,453 Bytes
d8a7ddd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import copy
import os
import sys
import unittest
import pickle
import weakref
import errno
from textwrap import dedent
from test.support import (captured_stderr, check_impl_detail,
cpython_only, gc_collect,
no_tracing, script_helper,
SuppressCrashReport,
force_not_colorized)
from test.support.import_helper import import_module
from test.support.os_helper import TESTFN, unlink
from test.support.warnings_helper import check_warnings
from test import support
def test_notes(self):
for e in [BaseException(1), Exception(2), ValueError(3)]:
with self.subTest(e=e):
self.assertFalse(hasattr(e, '__notes__'))
e.add_note("My Note")
self.assertEqual(e.__notes__, ["My Note"])
with self.assertRaises(TypeError):
e.add_note(42)
self.assertEqual(e.__notes__, ["My Note"])
e.add_note("Your Note")
self.assertEqual(e.__notes__, ["My Note", "Your Note"])
del e.__notes__
self.assertFalse(hasattr(e, '__notes__'))
e.add_note("Our Note")
self.assertEqual(e.__notes__, ["Our Note"])
e.__notes__ = 42
self.assertEqual(e.__notes__, 42)
with self.assertRaises(TypeError):
e.add_note("will not work")
self.assertEqual(e.__notes__, 42)
|