##// END OF EJS Templates
Test for local variable expansion in %magic commands.
Thomas Kluyver -
Show More
@@ -240,6 +240,8 b' class InteractiveShellTestCase(unittest.TestCase):'
240 ip.var_expand(u'echo $f')
240 ip.var_expand(u'echo $f')
241
241
242 def test_var_expand_local(self):
242 def test_var_expand_local(self):
243 """Test local variable expansion in !system and %magic calls"""
244 # !system
243 ip.run_cell('def test():\n'
245 ip.run_cell('def test():\n'
244 ' lvar = "ttt"\n'
246 ' lvar = "ttt"\n'
245 ' ret = !echo {lvar}\n'
247 ' ret = !echo {lvar}\n'
@@ -247,6 +249,14 b' class InteractiveShellTestCase(unittest.TestCase):'
247 res = ip.user_ns['test']()
249 res = ip.user_ns['test']()
248 nt.assert_in('ttt', res)
250 nt.assert_in('ttt', res)
249
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)
259
250 def test_bad_var_expand(self):
260 def test_bad_var_expand(self):
251 """var_expand on invalid formats shouldn't raise"""
261 """var_expand on invalid formats shouldn't raise"""
252 # SyntaxError
262 # SyntaxError
General Comments 0
You need to be logged in to leave comments. Login now