Show More
@@ -469,6 +469,16 class TestAstTransform(unittest.TestCase): | |||
|
469 | 469 | with tt.AssertPrints("CPU times"): |
|
470 | 470 | ip.run_line_magic("time", "a = f(-3 + -2)") |
|
471 | 471 | self.assertEqual(called, [5]) |
|
472 | ||
|
473 | def test_macro(self): | |
|
474 | ip.push({'a':10}) | |
|
475 | # The AST transformation makes this do a+=-1 | |
|
476 | ip.define_macro("amacro", "a+=1\nprint(a)") | |
|
477 | ||
|
478 | with tt.AssertPrints("9"): | |
|
479 | ip.run_cell("amacro") | |
|
480 | with tt.AssertPrints("8"): | |
|
481 | ip.run_cell("amacro") | |
|
472 | 482 | |
|
473 | 483 | class IntegerWrapper(ast.NodeTransformer): |
|
474 | 484 | """Wraps all integers in a call to Integer()""" |
General Comments 0
You need to be logged in to leave comments.
Login now