From 9e68e2734aecbad4afd8bbea750a03ba02f0cc18 2012-06-07 20:26:53 From: Thomas Kluyver Date: 2012-06-07 20:26:53 Subject: [PATCH] Test for local variable expansion in %magic commands. --- diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py index 9c5fbfa..98c6b58 100644 --- a/IPython/core/tests/test_interactiveshell.py +++ b/IPython/core/tests/test_interactiveshell.py @@ -240,12 +240,22 @@ class InteractiveShellTestCase(unittest.TestCase): ip.var_expand(u'echo $f') def test_var_expand_local(self): + """Test local variable expansion in !system and %magic calls""" + # !system ip.run_cell('def test():\n' ' lvar = "ttt"\n' ' ret = !echo {lvar}\n' ' return ret[0]\n') res = ip.user_ns['test']() nt.assert_in('ttt', res) + + # %magic + ip.run_cell('def makemacro():\n' + ' macroname = "macro_var_expand_locals"\n' + ' %macro {macroname} codestr\n') + ip.user_ns['codestr'] = "str(12)" + ip.run_cell('makemacro()') + nt.assert_in('macro_var_expand_locals', ip.user_ns) def test_bad_var_expand(self): """var_expand on invalid formats shouldn't raise"""