Skip to content

Commit

Permalink
Add another multiline rule test for good luck
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddyGuthridge committed Feb 12, 2025
1 parent 417d828 commit 6464236
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def transformer():
"simple": simple_rule,
"multiline": multiline_rule,
"echo": echo_rule,
"reprs": reprs_rule,
"error": error_rule,
"file_contents": file_contents,
}
Expand All @@ -120,6 +121,10 @@ def multiline_rule(text=""):
return f"Multiple\nLines {text}".strip()


def reprs_rule(*data: Any) -> str:
return "\n".join(repr(item) for item in data)


def echo_rule(value):
return value

Expand Down
9 changes: 8 additions & 1 deletion tests/transformer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,20 @@ def test_multiline_output_rule(transformer: TransdocTransformer):
)


def test_multiline_input_rule(transformer: TransdocTransformer):
def test_multiline_bracket_input_rule(transformer: TransdocTransformer):
assert (
transformer.transform("Call: {{multiline[sample\ntext]}}", "<string>")
== "Call: Multiple\nLines sample\ntext"
)


def test_multiline_python_fn_input_rule(transformer: TransdocTransformer):
assert (
transformer.transform("Call: {{reprs('sample',\n'text')}}", "<string>")
== "Call: 'sample'\n'text'"
)


def test_rules_respect_indentation(transformer: TransdocTransformer):
assert (
transformer.transform(
Expand Down

0 comments on commit 6464236

Please sign in to comment.