@@ -291,6 +291,60 @@ def test_active_cells_from_py_percent(
291
291
compare (text2 , text )
292
292
293
293
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\n 1 + 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\n 1 + 1"
343
+
344
+ text2 = jupytext .writes (nb , "py:light" )
345
+ compare (text2 , text )
346
+
347
+
294
348
def test_active_cells_from_py_light (
295
349
text = """# + active="py"
296
350
print('should only be displayed in py file')
0 commit comments