Skip to content

Commit 48aac09

Browse files
committed
Add failing test for suppressing exception chaining
1 parent ea49c86 commit 48aac09

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

IPython/core/tests/test_ultratb.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ class Python3ChainedExceptionsTest(unittest.TestCase):
173173
raise KeyError('uh')
174174
"""
175175

176+
SUPPRESS_CHAINING_CODE = """
177+
try:
178+
1/0
179+
except Exception:
180+
raise ValueError("Yikes") from None
181+
"""
182+
176183
def test_direct_cause_error(self):
177184
if PY3:
178185
with tt.AssertPrints(["KeyError", "NameError", "direct cause"]):
@@ -182,3 +189,9 @@ def test_exception_during_handling_error(self):
182189
if PY3:
183190
with tt.AssertPrints(["KeyError", "NameError", "During handling"]):
184191
ip.run_cell(self.EXCEPTION_DURING_HANDLING_CODE)
192+
193+
def test_suppress_exception_chaining(self):
194+
if PY3:
195+
with tt.AssertNotPrints("ZeroDivisionError"), \
196+
tt.AssertPrints("ValueError", suppress=False):
197+
ip.run_cell(self.SUPPRESS_CHAINING_CODE)

0 commit comments

Comments
 (0)