Skip to content

Commit

Permalink
Simplify and update test solving #186
Browse files Browse the repository at this point in the history
  • Loading branch information
bricoletc committed Jan 31, 2024
1 parent 8ee74cd commit 06d1f14
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions tests/test_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,7 @@ def test_wrap_line_in_run_directive(self):

def test_shell_indention_long_line(self):
"""https://github.com/snakemake/snakefmt/issues/186
test this rule
# test this rule:
rule test1:
input:
"...",
Expand All @@ -1407,33 +1407,16 @@ def test_shell_indention_long_line(self):
"param1",
[
"item1",
f"very_long_item2_{very_long_function(other_param)}"
if some_very_long_condition
else "",
(
f"very_long_item2_{{very_long_function(other_param)}}"
if some_very_long_condition
else "",
)
],
)
"""
snakecode = (
"rule test1:\n"
f"{TAB * 1}input:\n"
f'{TAB * 2}"...",\n'
f"{TAB * 1}output:\n"
f'{TAB * 2}"...",\n'
f"{TAB * 1}shell:\n"
f"{TAB * 2}myfunc(\n"
f'{TAB * 3}"param1",\n'
f"{TAB * 3}[\n"
f'{TAB * 4}"item1",\n'
f'{TAB * 4}f"very_long_item2_{{very_long_function(other_param)}}"\n'
f"{TAB * 4}if some_very_long_condition\n"
f'{TAB * 4}else "",\n'
f"{TAB * 3}],\n"
f"{TAB * 2})\n"
)
formatter = setup_formatter(snakecode)

expected = (
"rule test1:\n"
f"{TAB * 1}input:\n"
f'{TAB * 2}"...",\n'
Expand All @@ -1452,5 +1435,6 @@ def test_shell_indention_long_line(self):
f"{TAB * 3}],\n"
f"{TAB * 2})\n"
)
formatter = setup_formatter(snakecode)

assert formatter.get_formatted() == expected
assert formatter.get_formatted() == snakecode

0 comments on commit 06d1f14

Please sign in to comment.