##// END OF EJS Templates
Merge pull request #11330 from hongshaoyang/patch-1...
Matthias Bussonnier -
r24696:2f25f7dd merge
parent child Browse files
Show More
@@ -816,8 +816,11 b' class OSMagics(Magics):'
816 816 The file will be overwritten unless the -a (--append) flag is specified.
817 817 """
818 818 args = magic_arguments.parse_argstring(self.writefile, line)
819 filename = os.path.expanduser(args.filename)
820
819 if re.match(r'[\'*\']|["*"]', args.filename):
820 filename = os.path.expanduser(args.filename[1:-1])
821 else:
822 filename = os.path.expanduser(args.filename)
823
821 824 if os.path.exists(filename):
822 825 if args.append:
823 826 print("Appending to %s" % filename)
@@ -27,7 +27,8 b' from IPython.core.magics import execution, script, code, logging'
27 27 from IPython.testing import decorators as dec
28 28 from IPython.testing import tools as tt
29 29 from IPython.utils.io import capture_output
30 from IPython.utils.tempdir import TemporaryDirectory
30 from IPython.utils.tempdir import (TemporaryDirectory,
31 TemporaryWorkingDirectory)
31 32 from IPython.utils.process import find_cmd
32 33
33 34
@@ -797,7 +798,20 b' def test_file_amend():'
797 798 s = f.read()
798 799 nt.assert_in('line1\n', s)
799 800 nt.assert_in('line3\n', s)
800
801
802 def test_file_spaces():
803 """%%file with spaces in filename"""
804 ip = get_ipython()
805 with TemporaryWorkingDirectory() as td:
806 fname = "file name"
807 ip.run_cell_magic("file", '"%s"'%fname, u'\n'.join([
808 'line1',
809 'line2',
810 ]))
811 with open(fname) as f:
812 s = f.read()
813 nt.assert_in('line1\n', s)
814 nt.assert_in('line2', s)
801 815
802 816 def test_script_config():
803 817 ip = get_ipython()
General Comments 0
You need to be logged in to leave comments. Login now