##// END OF EJS Templates
Test that custom exceptions handlers can handle `SyntaxError`s
Matthias Bussonnier -
Show More
@@ -434,6 +434,21 b' class InteractiveShellTestCase(unittest.TestCase):'
434 found = ip._ofind('a.foo', [('locals', locals())])
434 found = ip._ofind('a.foo', [('locals', locals())])
435 nt.assert_is(found['obj'], A.foo)
435 nt.assert_is(found['obj'], A.foo)
436
436
437 def test_custom_syntaxerror_exception(self):
438 called = []
439 def my_handler(shell, etype, value, tb, tb_offset=None):
440 called.append(etype)
441 shell.showtraceback((etype, value, tb), tb_offset=tb_offset)
442
443 ip.set_custom_exc((SyntaxError,), my_handler)
444 try:
445 ip.run_cell("1f")
446 # Check that this was called, and only once.
447 self.assertEqual(called, [SyntaxError])
448 finally:
449 # Reset the custom exception hook
450 ip.set_custom_exc((), None)
451
437 def test_custom_exception(self):
452 def test_custom_exception(self):
438 called = []
453 called = []
439 def my_handler(shell, etype, value, tb, tb_offset=None):
454 def my_handler(shell, etype, value, tb, tb_offset=None):
General Comments 0
You need to be logged in to leave comments. Login now