Skip to content

Commit 97f73cc

Browse files
committed
Add a test to reproduce #1131
1 parent 15452de commit 97f73cc

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

tests/functional/others/test_active_cells.py

+54
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,60 @@ def test_active_cells_from_py_percent(
291291
compare(text2, text)
292292

293293

294+
def test_comments_work_in_active_cells_from_py_percent_1131(
295+
text="""# %% tags=["active-py"]
296+
# this is a comment
297+
""",
298+
):
299+
nb = jupytext.reads(text, "py:percent")
300+
assert nb.cells[0].cell_type == "raw"
301+
assert nb.cells[0].source == "# this is a comment"
302+
303+
text2 = jupytext.writes(nb, "py:percent")
304+
compare(text2, text)
305+
306+
307+
def test_comments_work_in_active_cells_from_py_light_1131(
308+
text="""# + tags=["active-py"]
309+
# this is a comment
310+
""",
311+
):
312+
nb = jupytext.reads(text, "py:light")
313+
assert nb.cells[0].cell_type == "raw"
314+
assert nb.cells[0].source == "# this is a comment"
315+
316+
text2 = jupytext.writes(nb, "py:light")
317+
compare(text2, text)
318+
319+
320+
def test_comments_plus_code_work_in_active_cells_from_py_percent_1131(
321+
text="""# %% tags=["active-py"]
322+
# this is a comment
323+
1 + 1
324+
""",
325+
):
326+
nb = jupytext.reads(text, "py:percent")
327+
assert nb.cells[0].cell_type == "raw"
328+
assert nb.cells[0].source == "# this is a comment\n1 + 1"
329+
330+
text2 = jupytext.writes(nb, "py:percent")
331+
compare(text2, text)
332+
333+
334+
def test_comments_plus_code_work_in_active_cells_from_py_light_1131(
335+
text="""# + tags=["active-py"]
336+
# this is a comment
337+
1 + 1
338+
""",
339+
):
340+
nb = jupytext.reads(text, "py:light")
341+
assert nb.cells[0].cell_type == "raw"
342+
assert nb.cells[0].source == "# this is a comment\n1 + 1"
343+
344+
text2 = jupytext.writes(nb, "py:light")
345+
compare(text2, text)
346+
347+
294348
def test_active_cells_from_py_light(
295349
text="""# + active="py"
296350
print('should only be displayed in py file')

0 commit comments

Comments
 (0)