File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -173,6 +173,13 @@ class Python3ChainedExceptionsTest(unittest.TestCase):
173
173
raise KeyError('uh')
174
174
"""
175
175
176
+ SUPPRESS_CHAINING_CODE = """
177
+ try:
178
+ 1/0
179
+ except Exception:
180
+ raise ValueError("Yikes") from None
181
+ """
182
+
176
183
def test_direct_cause_error (self ):
177
184
if PY3 :
178
185
with tt .AssertPrints (["KeyError" , "NameError" , "direct cause" ]):
@@ -182,3 +189,9 @@ def test_exception_during_handling_error(self):
182
189
if PY3 :
183
190
with tt .AssertPrints (["KeyError" , "NameError" , "During handling" ]):
184
191
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 )
You can’t perform that action at this time.
0 commit comments