##// END OF EJS Templates
Test for local variable expansion in %magic commands.
Thomas Kluyver -
Show More
@@ -240,12 +240,22 b' class InteractiveShellTestCase(unittest.TestCase):'
240 240 ip.var_expand(u'echo $f')
241 241
242 242 def test_var_expand_local(self):
243 """Test local variable expansion in !system and %magic calls"""
244 # !system
243 245 ip.run_cell('def test():\n'
244 246 ' lvar = "ttt"\n'
245 247 ' ret = !echo {lvar}\n'
246 248 ' return ret[0]\n')
247 249 res = ip.user_ns['test']()
248 250 nt.assert_in('ttt', res)
251
252 # %magic
253 ip.run_cell('def makemacro():\n'
254 ' macroname = "macro_var_expand_locals"\n'
255 ' %macro {macroname} codestr\n')
256 ip.user_ns['codestr'] = "str(12)"
257 ip.run_cell('makemacro()')
258 nt.assert_in('macro_var_expand_locals', ip.user_ns)
249 259
250 260 def test_bad_var_expand(self):
251 261 """var_expand on invalid formats shouldn't raise"""
General Comments 0
You need to be logged in to leave comments. Login now