Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide __repr__ for SnapshotAssertion #572

Closed
toryth opened this issue Nov 5, 2021 · 2 comments · Fixed by #600
Closed

provide __repr__ for SnapshotAssertion #572

toryth opened this issue Nov 5, 2021 · 2 comments · Fixed by #600
Labels
feature request New feature or request released

Comments

@toryth
Copy link

toryth commented Nov 5, 2021

Is your feature request related to a problem? Please describe.

Yes, when working in PyCharm I'll get output like

{'cache_key': None,
 'course_id': None,
 'lti_integration_id': 1,
 'message_type': 'LtiResourceLinkRequest',
 'redirect_url': None,
 'version': '1.3.0'} != <syrupy.assertion.SnapshotAssertion object at 0x7f6c2b084c70>

And when I "click to see difference" I'll get

image

Describe the solution you'd like

I believe SnapshotAssertion needs to provide a __repr__ method.

Describe alternatives you've considered

None

Additional context

I already looked at implementing this but got caught up on things relating to self._executions and self.index.

Another hurdle is the way serialization happens. For example

assert dict_of_dicts == snapshot

snapshot will serialize into something that has types and dict_of_dicts will not have types in its __repr__. We could remove the types on the snapshot but I think comparing on types is a good idea and by just removing the types from the representation the diff (comparing on one thing and representing as another) could lead to confusing results when the assertion fails but the diff looks the same.

This seems relevant https://github.com/JetBrains/intellij-community/blob/master/python/helpers/pycharm/teamcity/pytest_plugin.py#L289

@KaeganCasey
Copy link

I would love this feature as well! It's easy enough to look at the test name and go find it in the .ambr file but it would be amazing to be able to use the built in diffing in pycharm to spot differences easily

@tophat-opensource-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 2.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants