Show More
@@ -240,12 +240,22 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' | |
246 | ' return ret[0]\n') |
|
248 | ' return ret[0]\n') | |
247 | res = ip.user_ns['test']() |
|
249 | res = ip.user_ns['test']() | |
248 | nt.assert_in('ttt', res) |
|
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 | 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""" |
General Comments 0
You need to be logged in to leave comments.
Login now