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

Saved snapshot fails to match if repr ends with newline #925

Open
PhilReinhold opened this issue Dec 11, 2024 · 0 comments
Open

Saved snapshot fails to match if repr ends with newline #925

PhilReinhold opened this issue Dec 11, 2024 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers serializer Syrupy serializer question

Comments

@PhilReinhold
Copy link

Describe the bug

It appears that if you snapshot test against an object whose repr ends in a newline, then the test will fail even after running --snapshot-update

To reproduce

# test_syrupy.py
class X:
    def __repr__(self):
        return "X\n"


def test_syrupy(snapshot):
    assert X() == snapshot

Then run pytest test_syrupy.py --snapshot-update then pytest teest_syrupy.py

The test fails with the following output

test_syrupy.py F                                                                                                                                                                                         [100%]

=================================================================================================== FAILURES ===================================================================================================
_________________________________________________________________________________________________ test_syrupy __________________________________________________________________________________________________

snapshot = X

    def test_syrupy(snapshot):
>       assert X() == snapshot
E       assert [+ received] == [- snapshot]
E         - X
E         + X␤

Expected behavior

I expect the test to pass

Environment (please complete the following information):

  • OS: MacOS 14.7
  • Syrupy Version: 4.8.0
  • Python Version: 3.11.4
@noahnu noahnu added bug Something isn't working serializer Syrupy serializer question good first issue Good for newcomers labels Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers serializer Syrupy serializer question
Projects
None yet
Development

No branches or pull requests

2 participants