##// END OF EJS Templates
Add test for custom exception hook.
Thomas Kluyver -
Show More
@@ -337,6 +337,21 b' class InteractiveShellTestCase(unittest.TestCase):'
337 namespace = 'IPython internal', obj= cmagic.__wrapped__,
337 namespace = 'IPython internal', obj= cmagic.__wrapped__,
338 parent = None)
338 parent = None)
339 nt.assert_equal(find, info)
339 nt.assert_equal(find, info)
340
341 def test_custom_exception(self):
342 called = []
343 def my_handler(shell, etype, value, tb, tb_offset=None):
344 called.append(etype)
345 shell.showtraceback((etype, value, tb), tb_offset=tb_offset)
346
347 ip.set_custom_exc((ValueError,), my_handler)
348 try:
349 ip.run_cell("raise ValueError('test')")
350 # Check that this was called, and only once.
351 self.assertEqual(called, [ValueError])
352 finally:
353 # Reset the custom exception hook
354 ip.set_custom_exc((), None)
340
355
341
356
342 class TestSafeExecfileNonAsciiPath(unittest.TestCase):
357 class TestSafeExecfileNonAsciiPath(unittest.TestCase):
General Comments 0
You need to be logged in to leave comments. Login now