MCPcopy Index your code
hub / github.com/ipython/ipython / test_var_expand

Method test_var_expand

tests/test_interactiveshell.py:246–259  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

244 ip.reset()
245
246 def test_var_expand(self):
247 ip.user_ns["f"] = "Ca\xf1o"
248 self.assertEqual(ip.var_expand("echo $f"), "echo Ca\xf1o")
249 self.assertEqual(ip.var_expand("echo {f}"), "echo Ca\xf1o")
250 self.assertEqual(ip.var_expand("echo {f[:-1]}"), "echo Ca\xf1")
251 self.assertEqual(ip.var_expand("echo {1*2}"), "echo 2")
252
253 self.assertEqual(
254 ip.var_expand("grep x | awk '{print $1}'"), "grep x | awk '{print $1}'"
255 )
256
257 ip.user_ns["f"] = b"Ca\xc3\xb1o"
258 # This should not raise any exception:
259 ip.var_expand("echo $f")
260
261 def test_var_expand_local(self):
262 """Test local variable expansion in !system and %magic calls"""

Callers

nothing calls this directly

Calls 1

var_expandMethod · 0.80

Tested by

no test coverage detected