%%writefile -a amends files
()
| 1372 | |
| 1373 | |
| 1374 | def 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 | |
| 1404 | def test_file_spaces(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…