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

Function test_file_var_expand

IPython/core/tests/test_magic.py:892–905  ·  view source on GitHub ↗

%%writefile $filename

()

Source from the content-addressed store, hash-verified

890 nt.assert_in('line2', s)
891
892def test_file_var_expand():
893 """%%writefile $filename"""
894 ip = get_ipython()
895 with TemporaryDirectory() as td:
896 fname = os.path.join(td, 'file1')
897 ip.user_ns['filename'] = fname
898 ip.run_cell_magic("writefile", '$filename', u'\n'.join([
899 'line1',
900 'line2',
901 ]))
902 with open(fname) as f:
903 s = f.read()
904 nt.assert_in('line1\n', s)
905 nt.assert_in('line2', s)
906
907def test_file_unicode():
908 """%%writefile with unicode cell"""

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