From 9454c26fbbeca878f7bb637fae86d55defbeee67 2012-09-27 15:17:58 From: Thomas Kluyver Date: 2012-09-27 15:17:58 Subject: [PATCH] Add test that macros are affected by AST transformations --- diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py index 652fefc..9bdee83 100644 --- a/IPython/core/tests/test_interactiveshell.py +++ b/IPython/core/tests/test_interactiveshell.py @@ -469,6 +469,16 @@ class TestAstTransform(unittest.TestCase): with tt.AssertPrints("CPU times"): ip.run_line_magic("time", "a = f(-3 + -2)") self.assertEqual(called, [5]) + + def test_macro(self): + ip.push({'a':10}) + # The AST transformation makes this do a+=-1 + ip.define_macro("amacro", "a+=1\nprint(a)") + + with tt.AssertPrints("9"): + ip.run_cell("amacro") + with tt.AssertPrints("8"): + ip.run_cell("amacro") class IntegerWrapper(ast.NodeTransformer): """Wraps all integers in a call to Integer()"""