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

Function test_file_var_expand

tests/test_magic.py:1332–1350  ·  view source on GitHub ↗

%%writefile $filename

()

Source from the content-addressed store, hash-verified

1330
1331
1332def test_file_var_expand():
1333 """%%writefile $filename"""
1334 ip = get_ipython()
1335 with TemporaryDirectory() as td:
1336 fname = os.path.join(td, "file1")
1337 ip.user_ns["filename"] = fname
1338 ip.run_cell_magic(
1339 "writefile",
1340 "$filename",
1341 "\n".join(
1342 [
1343 "line1",
1344 "line2",
1345 ]
1346 ),
1347 )
1348 s = Path(fname).read_text(encoding="utf-8")
1349 assert "line1\n" in s
1350 assert "line2" in s
1351
1352
1353def test_file_unicode():

Callers

nothing calls this directly

Calls 2

get_ipythonFunction · 0.90
run_cell_magicMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…