Skip to content

Commit

Permalink
fix: remove added trailing whitespace from multiline string
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah Negin-Ulster committed Apr 17, 2020
1 parent da8826a commit 1750d03
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/syrupy/extensions/amber.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def serialize_string(
return (
cls.with_indent("'\n", depth)
+ str(data)
+ cls.with_indent("\n'", depth)
+ "\n"
+ cls.with_indent("'", depth)
)
return cls.with_indent(repr(data), depth)

Expand Down
8 changes: 8 additions & 0 deletions tests/__snapshots__/test_extension_amber.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@
},
]
---
# name: test_list_in_dict
<class 'dict'> {
'value': '
line 1
line 2
',
}
---
# name: test_multiple_snapshots
'First.'
---
Expand Down
5 changes: 5 additions & 0 deletions tests/test_extension_amber.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def test_newline_control_characters(snapshot):
assert snapshot == "line 1\r\nline 2\r\n"


def test_list_in_dict(snapshot):
lines = "\n".join(["line 1", "line 2"])
assert {"value": lines} == snapshot


@pytest.mark.parametrize("actual", [False, True])
def test_bool(actual, snapshot):
assert actual == snapshot
Expand Down

0 comments on commit 1750d03

Please sign in to comment.