From 6fa3cab2648677bf14ddca896cdc41a699f18a49 Mon Sep 17 00:00:00 2001 From: Marc Wouts Date: Wed, 22 Sep 2021 22:02:42 +0200 Subject: [PATCH] More tests on cell_markers=""" (#856) --- tests/test_cell_markers.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/test_cell_markers.py diff --git a/tests/test_cell_markers.py b/tests/test_cell_markers.py new file mode 100644 index 000000000..2ae38c4d0 --- /dev/null +++ b/tests/test_cell_markers.py @@ -0,0 +1,33 @@ +from nbformat.v4.nbbase import new_raw_cell + +from jupytext import reads, writes +from jupytext.cli import jupytext + + +def test_set_cell_markers_cli(tmpdir, cwd_tmpdir): + tmpdir.join("test.py").write("# %% [markdown]\n# A Markdown cell\n") + jupytext(["--format-options", 'cell_markers="""', "test.py"]) + py = tmpdir.join("test.py").read() + assert py.endswith('# %% [markdown]\n"""\nA Markdown cell\n"""\n') + + +def test_add_cell_to_script_with_cell_markers( + no_jupytext_version_number, + py='''# --- +# jupyter: +# jupytext: +# formats: py:percent +# cell_markers: '"""' +# --- +''', +): + nb = reads(py, fmt="py:percent") + nb.cells = [new_raw_cell("A raw cell")] + py2 = writes(nb, fmt="py:percent") + assert py2.endswith( + '''# %% [raw] +""" +A raw cell +""" +''' + )