You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 theto_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.
The text was updated successfully, but these errors were encountered: