joseph-roitman / pytest-snapshot

A plugin for snapshot testing with pytest.
MIT License
114 stars 12 forks source link

Comparison during snapshot update should use `compare` function. #60

Open jessemyers opened 1 year ago

jessemyers commented 1 year ago

This line:

if encoded_expected_value is None or encoded_value != encoded_expected_value:

is using != rather than relying on the internal compare function, which means that this code cannot be adapted easily to types that do not support regular Python comparison, especially numpy arrays.

(Aside, it'd be especially nice if the Snapshot class allowed compare/encode/decode to be customized more easily; I'm currently experimenting with array comparison using numpy.allclose() by patching the internal _get_compare_encode_decode function.)