MCPcopy Create free account
hub / github.com/ipython/ipython / test_file_amend

Function test_file_amend

IPython/core/tests/test_magic.py:921–937  ·  view source on GitHub ↗

%%writefile -a amends files

()

Source from the content-addressed store, hash-verified

919 nt.assert_in(u'liné2', s)
920
921def test_file_amend():
922 """%%writefile -a amends files"""
923 ip = get_ipython()
924 with TemporaryDirectory() as td:
925 fname = os.path.join(td, 'file2')
926 ip.run_cell_magic("writefile", fname, u'\n'.join([
927 'line1',
928 'line2',
929 ]))
930 ip.run_cell_magic("writefile", "-a %s" % fname, u'\n'.join([
931 'line3',
932 'line4',
933 ]))
934 with open(fname) as f:
935 s = f.read()
936 nt.assert_in('line1\n', s)
937 nt.assert_in('line3\n', s)
938
939def test_file_spaces():
940 """%%file with spaces in filename"""

Callers

nothing calls this directly

Calls 3

get_ipythonFunction · 0.90
run_cell_magicMethod · 0.80
readMethod · 0.80

Tested by

no test coverage detected