From 48aac09dd0a5a94ce135deb1adcf12f9d8b57907 2015-07-09 14:15:39 From: Thomas Kluyver Date: 2015-07-09 14:15:39 Subject: [PATCH] Add failing test for suppressing exception chaining --- diff --git a/IPython/core/tests/test_ultratb.py b/IPython/core/tests/test_ultratb.py index c823d76..25815c9 100644 --- a/IPython/core/tests/test_ultratb.py +++ b/IPython/core/tests/test_ultratb.py @@ -173,6 +173,13 @@ except Exception as e: raise KeyError('uh') """ + SUPPRESS_CHAINING_CODE = """ +try: + 1/0 +except Exception: + raise ValueError("Yikes") from None + """ + def test_direct_cause_error(self): if PY3: with tt.AssertPrints(["KeyError", "NameError", "direct cause"]): @@ -182,3 +189,9 @@ except Exception as e: if PY3: with tt.AssertPrints(["KeyError", "NameError", "During handling"]): ip.run_cell(self.EXCEPTION_DURING_HANDLING_CODE) + + def test_suppress_exception_chaining(self): + if PY3: + with tt.AssertNotPrints("ZeroDivisionError"), \ + tt.AssertPrints("ValueError", suppress=False): + ip.run_cell(self.SUPPRESS_CHAINING_CODE)