Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2014)

#24780: unittest assertEqual difference output foiled by newlines

Can't Edit
Can't Publish+Mail
Start Review
Created:
3 years, 1 month ago by chris.jerdonek
Modified:
2 years, 6 months ago
Reviewers:
robertc
CC:
tim.peters, loewis, rbcollins, ezio.melotti, r.david.murray, Michael Foord, cjerdonek, Elena.Oat, Anish.Shah, pynewbie, Adrian, xtreak, nanjekyejoannah_gmail.com
Visibility:
Public.

Patch Set 1 #

Total comments: 2

Patch Set 2 #

Unified diffs Side-by-side diffs Delta from patch set Stats Patch
Lib/unittest/case.py View 1 2 chunks +9 lines, -1 line 0 comments Download

Messages

Total messages: 1
rbcollins
3 years ago #1
http://bugs.python.org/review/24780/diff/16476/Lib/unittest/case.py
File Lib/unittest/case.py (right):

http://bugs.python.org/review/24780/diff/16476/Lib/unittest/case.py#newcode1190
Lib/unittest/case.py:1190: secondlines[len(secondlines)-1])
There's a bug here. You are transforming the two inputs separately, but by doing
that, we can make dissimilar inputs compare equal.

assertEqual('', '\n') should be enough to demonstrate that.

http://bugs.python.org/review/24780/diff/16476/Lib/unittest/case.py#newcode1306
Lib/unittest/case.py:1306: def _appendNewLineChar(self, line):
This function name is confusing to me: it doesn't add a new line character if
the line already ends with \r or \n. Something like _ensure_newline(self, line)
would do.

And since it doesn't need to access self, just make it a free function.
Sign in to reply to this message.

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+