@@ -294,50 +294,71 @@ def test_arg_very_looong(self):
294294 snakecode = (
295295 "if 1:\n "
296296 "\n "
297- " rule a:\n "
298- " input:\n "
299- ' a="a",\n '
300- " run:\n "
301- " for i in range(3):\n "
302- " a = list(\n "
303- ' "a",\n '
304- ' "' + ("a" * 68 ) + '",\n '
305- " )\n "
306- " b = list(\n "
307- " ''.format(\n "
308- ' "' + ("b" * 117 ) + '",\n '
309- ' b="b"\n '
310- " )\n "
311- " )\n "
297+ " rule a:\n "
298+ " input:\n "
299+ ' a="a",\n '
300+ " run:\n "
301+ " for i in range(3):\n "
302+ " a = list(\n "
303+ ' "a",\n '
304+ ' "' + ("a" * 68 ) + '",\n '
305+ " )\n "
306+ " b = list(\n "
307+ " ''.format(\n "
308+ ' "' + ("b" * 117 ) + '",\n '
309+ ' b="b"\n '
310+ " )\n "
311+ " )\n "
312312 "\n "
313- " rule b:\n "
314- " shell:\n "
315- ' "echo 1"\n '
313+ " rule b:\n "
314+ " shell:\n "
315+ ' "echo 1"\n '
316316 "\n "
317317 )
318- formatter = setup_formatter (snakecode )
319- actual = formatter .get_formatted ()
320- assert actual == setup_formatter (actual ).get_formatted ()
318+ expected = (
319+ f"if 1:\n "
320+ f"\n "
321+ f"{ TAB * 1 } rule a:\n "
322+ f"{ TAB * 2 } input:\n "
323+ f'{ TAB * 3 } a="a",\n '
324+ f"{ TAB * 2 } run:\n "
325+ f"{ TAB * 3 } for i in range(3):\n "
326+ f"{ TAB * 4 } a = list(\n "
327+ f'{ TAB * 5 } "a",\n '
328+ f'{ TAB * 5 } "' + ("a" * 68 ) + '",\n '
329+ f"{ TAB * 4 } )\n "
330+ f"{ TAB * 4 } b = list(\n "
331+ f'{ TAB * 5 } "".format(\n '
332+ f'{ TAB * 6 } "' + ("b" * 117 ) + '",\n '
333+ f'{ TAB * 6 } b="b",\n '
334+ f"{ TAB * 5 } )\n "
335+ f"{ TAB * 4 } )\n "
336+ f"\n "
337+ f"{ TAB * 1 } rule b:\n "
338+ f"{ TAB * 2 } shell:\n "
339+ f'{ TAB * 3 } "echo 1"\n '
340+ )
341+ actual = setup_formatter (snakecode ).get_formatted ()
342+ assert actual == expected
321343
322344 def test_param_inline_formatting (self ):
323- """issue 240 and 242"""
345+ """issue 208, 240 and 242"""
324346 snakecode = (
325- "rule call_variants:\n "
326- " input:\n "
327- " data=(\n "
328- " # a comment on the below\n "
329- ' "input_1.txt"\n '
330- " ),\n "
331- " threads:\n "
332- " max(\n "
333- " 1,\n "
334- ' int(config["params"]["call_variants"]["threads"]) - \n '
335- ' int(config["params"]["call_variants"]["compress-threads"])\n '
336- " )\n "
347+ f "rule call_variants:\n "
348+ f" { TAB * 1 } input:\n "
349+ f" { TAB * 2 } data=(\n "
350+ f" { TAB * 3 } # a comment on the below\n "
351+ f' { TAB * 3 } "input_1.txt"\n '
352+ f" { TAB * 2 } ),\n "
353+ f" { TAB * 1 } threads:\n "
354+ f" { TAB * 2 } max(\n "
355+ f" { TAB * 3 } 1,\n "
356+ f' { TAB * 3 } int(config["params"]["call_variants"]["threads"])\n '
357+ f' { TAB * 3 } - int(config["params"]["call_variants"]["compress-threads"]), \n '
358+ f" { TAB * 2 } )\n "
337359 )
338- formatter = setup_formatter (snakecode )
339- actual = formatter .get_formatted ()
340- assert actual == setup_formatter (actual ).get_formatted ()
360+ actual = setup_formatter (snakecode ).get_formatted ()
361+ assert actual == snakecode
341362
342363
343364class TestSimplePythonFormatting :
@@ -1197,7 +1218,7 @@ def test_repeated_parameter_keyword_no_spacing(self):
11971218 assert formatter .get_formatted () == replaced
11981219
11991220 def test_repeated_parameter_keyword_comment_in_between_no_spacing (self ):
1200- snakecode = 'include: "a"\n # A comment\n # c2\n include: "b"\n '
1221+ snakecode = 'include: "a"\n # A comment\n ' ' # c2\n include: "b"\n '
12011222 expected = 'include: "a"\n # A comment\n # c2\n include: "b"\n '
12021223 assert setup_formatter (snakecode ).get_formatted () == expected
12031224
0 commit comments