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

Updated diff to show \t in string comparison assertions #10961

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

mthaitan
Copy link

@mthaitan mthaitan commented May 3, 2023

Closes #10704

Added "\t" characters to the diff message, did not add "\n" because the diff already creates each line on a separate line and it shows in the "AssertionError: ______" section of the error message.
Updated test suite to reflect this change.

Before:
A21FBA6C-69C9-4DB4-8560-2359DFF974AC

After:

pytest.param(
        """
        def test_this():
            result =   '''spam    bacon
            eggs love'''
            desired = "spam bacon eggs love"
            assert result == desired
        """,
        """
        >       assert result == desired
        E       AssertionError: assert 'spam    bacon\\n    eggs love' == 'spam bacon eggs love'
        E         - spam bacon eggs love
        E         + spam\\tbacon
        E         + \\teggs love
        """,
        id='Test "not in" string',
    ),

Worked with @egwetzel on this issue in team with @HSamiul.

Comment on lines +268 to +278
result = '''spam bacon
eggs love'''
desired = "spam bacon eggs love"
assert result == desired
""",
"""
> assert result == desired
E AssertionError: assert 'spam bacon\\n eggs love' == 'spam bacon eggs love'
E - spam bacon eggs love
E + spam\\tbacon
E + \\teggs love
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong to me - there are no tab characters in the original strings, so we're actually lying about the contents by replacing four spaces!

I think we need a different approach, perhaps showing the repr of the explanation lines in question if they differ in their trailing whitespace; or maybe only showing that for the trailing whitespace in question. Check out what the short summary does I guess?

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

Successfully merging this pull request may close these issues.

Show whitespace escape code in string diffs
3 participants