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

Function test_file_amend

tests/test_magic.py:1374–1401  ·  view source on GitHub ↗

%%writefile -a amends files

()

Source from the content-addressed store, hash-verified

1372
1373
1374def test_file_amend():
1375 """%%writefile -a amends files"""
1376 ip = get_ipython()
1377 with TemporaryDirectory() as td:
1378 fname = os.path.join(td, "file2")
1379 ip.run_cell_magic(
1380 "writefile",
1381 fname,
1382 "\n".join(
1383 [
1384 "line1",
1385 "line2",
1386 ]
1387 ),
1388 )
1389 ip.run_cell_magic(
1390 "writefile",
1391 "-a %s" % fname,
1392 "\n".join(
1393 [
1394 "line3",
1395 "line4",
1396 ]
1397 ),
1398 )
1399 s = Path(fname).read_text(encoding="utf-8")
1400 assert "line1\n" in s
1401 assert "line3\n" in s
1402
1403
1404def test_file_spaces():

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…