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

Issue 1553: Include terminal newlines in diffs #1634

Merged
merged 1 commit into from
Jun 22, 2016

Conversation

tomviner
Copy link
Contributor

Fix for #1553

By default Python's splitlines method splits so "a terminal line break does not result in an extra line". This means that comparing strings that differ only in whether they contain a terminal newline, results in a bad diff.

This PR sets splitlines' keepends=True, which keeps all newlines when splitting.

@tomviner
Copy link
Contributor Author

Note: the linting will fail because we added @RedBeardCode to Changelog links in another PR.

@coveralls
Copy link

coveralls commented Jun 21, 2016

Coverage Status

Coverage remained the same at 92.205% when pulling b13a046 on tomviner:issue1553/diff-final-newline into 5d8d1db on pytest-dev:master.

@nicoddemus
Copy link
Member

@tomviner could you please fix the conflicts? 😁

@@ -225,9 +225,11 @@ def _diff_text(left, right, verbose=False):
'characters in diff, use -v to show') % i]
left = left[:-i]
right = right[:-i]
# We set splitlines' keepends=True, which can only be passed as a
# positional argument
Copy link
Member

Choose a reason for hiding this comment

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

In this cases I usually just write:

splitlines = True
...
left.splitlines(splitlines)

But really is just a matter of style, no need to change it. 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @nicoddemus Nice suggestion, applied.

@nicoddemus
Copy link
Member

@tomviner could you please rebase/resolve conflicts on this branch? Thanks!

@tomviner tomviner force-pushed the issue1553/diff-final-newline branch from b13a046 to 608d393 Compare June 22, 2016 07:48
@tomviner tomviner force-pushed the issue1553/diff-final-newline branch from 608d393 to 98adf20 Compare June 22, 2016 07:52
@tomviner
Copy link
Contributor Author

@nicoddemus rebased :-)

@coveralls
Copy link

coveralls commented Jun 22, 2016

Coverage Status

Coverage increased (+0.0009%) to 92.24% when pulling 98adf20 on tomviner:issue1553/diff-final-newline into 144dc12 on pytest-dev:master.

@coveralls
Copy link

coveralls commented Jun 22, 2016

Coverage Status

Coverage increased (+0.0009%) to 92.24% when pulling 98adf20 on tomviner:issue1553/diff-final-newline into 144dc12 on pytest-dev:master.

@nicoddemus
Copy link
Member

@tomviner this failed on Windows... if you like, you can sit near me and we can debug it from my laptop.

@tomviner
Copy link
Contributor Author

@nicoddemus yes please. It maybe Windows line ending related.

@nicoddemus
Copy link
Member

nicoddemus commented Jun 22, 2016

Actually it didn't even run because of some error in AppVeyor. Going to run it locally and see what happens.

@nicoddemus nicoddemus merged commit 98adf20 into pytest-dev:master Jun 22, 2016
@nicoddemus
Copy link
Member

Done, thanks!

@nicoddemus
Copy link
Member

@tomviner just a quick tip: next time put something like this in one of the commits: Fix #1553 (or resolve/closes and some others), this way the issue gets closed automatically when merged. 😉

More info here.

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.

3 participants