Show More
@@ -1703,9 +1703,6 b' class InteractiveShell(SingletonConfigurable):' | |||
|
1703 | 1703 | elif etype is UsageError: |
|
1704 | 1704 | self.write_err("UsageError: %s" % value) |
|
1705 | 1705 | else: |
|
1706 | if etype in self.custom_exceptions: | |
|
1707 | stb = self.CustomTB(etype, value, tb, tb_offset) | |
|
1708 | else: | |
|
1709 | 1706 |
|
|
1710 | 1707 |
|
|
1711 | 1708 |
|
@@ -338,6 +338,21 b' class InteractiveShellTestCase(unittest.TestCase):' | |||
|
338 | 338 | parent = None) |
|
339 | 339 | nt.assert_equal(find, info) |
|
340 | 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) | |
|
355 | ||
|
341 | 356 | |
|
342 | 357 | class TestSafeExecfileNonAsciiPath(unittest.TestCase): |
|
343 | 358 |
General Comments 0
You need to be logged in to leave comments.
Login now