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 authored and noahnu committed Apr 19, 2020
1 parent 5b7c6e3 commit 24f3d57
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 @@ -160,6 +160,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 24f3d57

Please sign in to comment.