Skip to content

Commit

Permalink
Test that indented help calls are correctly commented out
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Jul 21, 2020
1 parent 97f2eaf commit 128bb3e
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions tests/test_read_simple_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import jupytext
from jupytext.compare import compare_notebooks
from .utils import skip_if_dict_is_not_ordered
import pytest


def test_read_simple_file(
Expand Down Expand Up @@ -1184,21 +1185,39 @@ def test_arg(arg):
assert nb.cells[0].metadata == {}


def test_indented_magic_commands(
text="""if True:
@pytest.mark.parametrize(
"script,cell",
[
(
"""if True:
# # !rm file 1
# !rm file 2
""",
):
"""if True:
# !rm file 1
!rm file 2""",
),
(
"""# +
if True:
# help?
# ?help
# # ?help
# # help?
""",
"""if True:
help?
?help
# ?help
# help?""",
),
],
)
def test_indented_magic_commands(script, cell):

nb = jupytext.reads(text, "py")
nb = jupytext.reads(script, "py")
assert len(nb.cells) == 1
assert nb.cells[0].cell_type == "code"
compare(
nb.cells[0].source,
"""if True:
# !rm file 1
!rm file 2""",
)
compare(nb.cells[0].source, cell)
assert nb.cells[0].metadata == {}
compare(jupytext.writes(nb, "py"), text)
compare(jupytext.writes(nb, "py"), script)

0 comments on commit 128bb3e

Please sign in to comment.