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

PyCharm diff comparison failure doesn't work with custom classes #675

Open
lindenwells opened this issue Jan 4, 2023 · 1 comment
Open
Labels
feature request New feature or request

Comments

@lindenwells
Copy link

lindenwells commented Jan 4, 2023

Describe the bug

When comparing a failed snapshot test on an object without a custom __repr__ (i.e. relies on syrupy's serializer), PyCharm incorrectly displays the actual output as the default __repr__ (e.g. ...Mansion object at 0xBEEF2020) instead of what syrupy serialises it to (e.g. Mansion(rooms=[Room(...)])).

This might be a PyCharm bug, or Syrupy or somehow both. Just thought I'd make this issue as it tripped me up at work for over an hour and I imagine a fair few people use PyCharm and syrupy together.

To reproduce

  1. checkout this repo I made
  2. create a virtualenv within and pip install syrupy==3.0.2
  3. find the singular test within the run configurations and notice that it fails.
  4. in the failed test output, scroll to the clickable '<Click to see difference>' text: image
  5. click that text and you should get a Comparison Failure interface like this: image

Expected behavior

This is roughly what I should see in the Comparison Failure window.
image
I know this is wrong because when I run pytest --snapshot-update, it updates the snapshot like this.

Screenshots
added throughout where appropriate

Environment:

  • OS: Windows 11 Pro 21H2
  • Syrupy Version: 3.0.2
  • Python Version: 3.9.13
  • PyCharm Version: 2022.3 (Community Edition), Build #PC-223.7571.203, built on December 1, 2022, Runtime version: 17.0.5+1-b653.14 amd64, VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

Additional context

This is similar to #572 but not the same.

@noahnu noahnu added the feature request New feature or request label Jan 9, 2023
@Crown0815
Copy link

Similar issue here with basic strings:

Create snapshot from:

def test_test(snapshot):
    test = """Hello to
the world"""
    assert test == snapshot
pytest --snapshot-update

Modify the string (e.g., add ! to world)

def test_test(snapshot):
    test = """Hello to
the world!"""                   # Added the `!`
    assert test == snapshot

Yields non-helpful diff view:

image

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
Projects
None yet
Development

No branches or pull requests

3 participants