-
Notifications
You must be signed in to change notification settings - Fork 103
Open
Description
Here's an example of how the snapshot is currently formatted:
snapshots['test_foo 1'] = '''ID Name Description
------------------------------------ ------------ -------------------------------
32fd8c27-9110-463f-89c0-eb676814923a Item 1 An item with a long description
32fd8c27-9110-463f-89c0-eb676814923a Item 2
32fd8c27-9110-463f-89c0-eb676814923a Another item
'''
I think the following is better for reviewing the snapshots, and is the exact same string:
snapshots['test_foo 1'] = '''\
ID Name Description
------------------------------------ ------------ -------------------------------
32fd8c27-9110-463f-89c0-eb676814923a Item 1 An item with a long description
32fd8c27-9110-463f-89c0-eb676814923a Item 2
32fd8c27-9110-463f-89c0-eb676814923a Another item
'''
I can provide a PR if this would be accepted
In the meantime, I'm using
from snapshottest.formatter import Formatter
from snapshottest.formatters import TypeFormatter, format_str
def format_str_custom(value, indent, formatter):
formatted = format_str(value, indent, formatter)
return re.sub(r"^(['\"]{3})(.*)", r"\1\\\n\2", formatted)
Formatter.register_formatter(TypeFormatter((str,), format_str_custom))
spenserblack
Metadata
Metadata
Assignees
Labels
No labels