Show More
@@ -769,6 +769,34 b' def test_file():' | |||||
769 | nt.assert_in('line1\n', s) |
|
769 | nt.assert_in('line1\n', s) | |
770 | nt.assert_in('line2', s) |
|
770 | nt.assert_in('line2', s) | |
771 |
|
771 | |||
|
772 | def test_file_single_quote(): | |||
|
773 | """Basic %%writefile with embedded single quotes""" | |||
|
774 | ip = get_ipython() | |||
|
775 | with TemporaryDirectory() as td: | |||
|
776 | fname = os.path.join(td, '\'file1\'') | |||
|
777 | ip.run_cell_magic("writefile", fname, u'\n'.join([ | |||
|
778 | 'line1', | |||
|
779 | 'line2', | |||
|
780 | ])) | |||
|
781 | with open(fname) as f: | |||
|
782 | s = f.read() | |||
|
783 | nt.assert_in('line1\n', s) | |||
|
784 | nt.assert_in('line2', s) | |||
|
785 | ||||
|
786 | def test_file_double_quote(): | |||
|
787 | """Basic %%writefile with embedded double quotes""" | |||
|
788 | ip = get_ipython() | |||
|
789 | with TemporaryDirectory() as td: | |||
|
790 | fname = os.path.join(td, '"file1"') | |||
|
791 | ip.run_cell_magic("writefile", fname, u'\n'.join([ | |||
|
792 | 'line1', | |||
|
793 | 'line2', | |||
|
794 | ])) | |||
|
795 | with open(fname) as f: | |||
|
796 | s = f.read() | |||
|
797 | nt.assert_in('line1\n', s) | |||
|
798 | nt.assert_in('line2', s) | |||
|
799 | ||||
772 | def test_file_var_expand(): |
|
800 | def test_file_var_expand(): | |
773 | """%%writefile $filename""" |
|
801 | """%%writefile $filename""" | |
774 | ip = get_ipython() |
|
802 | ip = get_ipython() |
General Comments 0
You need to be logged in to leave comments.
Login now