joseph-roitman / pytest-snapshot

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

Adding the possibility of skipping keys when comparing dict #33

Closed phasath closed 3 years ago

phasath commented 3 years ago

Hi! Great job on this snapshot test. I use it a lot and I believe that it would be a very good thing if we add a way to not compare some keys when doing the assert_match. It's very useful when we have time, for instance, involved.

joseph-roitman commented 3 years ago

Thanks :) You are not the first to request this feature. As in #14 and #29 I think normalizing the thing you want to snapshot is the better solution. Either by deleting the key you want from the dictionary, or by setting it to some constant. (e.g. 1970-01-01).

Do you agree? If you agree, I should probably add this to the documentation somewhere. If you don't agree, why do you think adding some type of custom comparison is better than normalizing the snapshotted object?