syrusakbary / snapshottest

Snapshot Testing utils for Python 📸
MIT License
525 stars 102 forks source link

Multiline bytes? #171

Open spenserblack opened 7 months ago

spenserblack commented 7 months ago

I'm snapshot testing a text file that gets generated in memory. The returned value is bytes. When a value is bytes, it currently is always on one line, like this:

b'HEADER\r\ncontent'

It would be nice if bytes could be multiline, similar to strings, like this:

b'''HEADER\r
content'''

Of course, there are going to be bytes that are binary and don't really contain any readable text to format. Perhaps .isalnum() can be used as a best guess if the bytes are text that should be multiline vs binary that should not be multiline.

The current workaround is to just decode the bytes to a string first so that the snapshot test is prettier. However, ideally, I feel that there shouldn't be any "processing" between the actual value and the tested/asserted value.