Skip to content

[py] consequences of allowing snapshots based on repr #516

@nedtwigg

Description

@nedtwigg

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.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions