##// END OF EJS Templates
Add test that a failing ast_transformer is unregistered.
Thomas Kluyver -
Show More
@@ -438,6 +438,22 b' class TestAstTransform(unittest.TestCase):'
438 with tt.AssertNotPrints('-55'):
438 with tt.AssertNotPrints('-55'):
439 ip.run_cell('print (n)')
439 ip.run_cell('print (n)')
440
440
441 class ErrorTransformer(ast.NodeTransformer):
442 """Throws an error when it sees a number."""
443 def visit_Num(self):
444 raise ValueError("test")
445
446 class TestAstTransformError(unittest.TestCase):
447 def test_unregistering(self):
448 err_transformer = ErrorTransformer()
449 ip.ast_transformers.append(err_transformer)
450
451 with tt.AssertPrints("unregister", channel='stderr'):
452 ip.run_cell("1 + 2")
453
454 # This should have been removed.
455 nt.assert_not_in(err_transformer, ip.ast_transformers)
456
441 def test__IPYTHON__():
457 def test__IPYTHON__():
442 # This shouldn't raise a NameError, that's all
458 # This shouldn't raise a NameError, that's all
443 __IPYTHON__
459 __IPYTHON__
General Comments 0
You need to be logged in to leave comments. Login now