PEP 415: Implement suppression of __context__ display with an exception attribute

This replaces the original PEP 409 implementation. See #14133.
This commit is contained in:
Benjamin Peterson 2012-05-14 22:09:31 -07:00
parent d91dc62379
commit d5a1c44455
12 changed files with 80 additions and 79 deletions

View file

@ -174,11 +174,14 @@ class TestCause(unittest.TestCase):
raise ValueError from None
except ValueError as exc:
self.assertIsNone(exc.__cause__)
raise exc from Ellipsis
self.assertTrue(exc.__suppress_context__)
exc.__suppress_context__ = False
raise exc
except ValueError as exc:
e = exc
self.assertIs(e.__cause__, Ellipsis)
self.assertIsNone(e.__cause__)
self.assertFalse(e.__suppress_context__)
self.assertIsInstance(e.__context__, TypeError)
def test_invalid_cause(self):