[py] consequences of allowing snapshots based on repr
Open
py
- Dominant language
- Kotlin
- Stars
- 101
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
Python has a very cool `repr()` method, which returns the source code required to create the object. Not everything implements it, but Python's core datastructures do.
For inline snapshots it's pretty easy - we call `repr()` on argument, and put that inside the `to_be()` call.
For disk snapshots, we would have to read the value from the snapshot, call `eval()` on that string, and then hope that the comparison logic is implemented correctly.
In both cases, it muddies the concept of equality a bit, but allowing repr is so convenient that it's worth it.

Contributor guide
Assessment
This issue has not been assessed yet.