syrusakbary / snapshottest

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

Save bytes/str snapshot in a file directly #157

Open shamrin opened 3 years ago

shamrin commented 3 years ago

I would like to test a code that produces PNG file as bytes. Snapshot should be saved as PNG file directly. GitHub PRs would become super useful, because I can compare pictures directly just by looking at them:

github image diff demo

There is FileSnapshot functionality, but it's not directly useful for my case. FileSnapshot requires file path as an argument. I need to assert file content. Temporary file would work, but seems a bit extra and probably slower.

It would be cool to have something like snapshot.assert_match(png_content, save_as='.png').

Thoughts?