classification
Title: unittest assertEqual error output sub-optimal for single strings
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: michael.foord Nosy List: michael.foord, r.david.murray
Priority: normal Keywords: patch

Created on 2010-07-06 04:02 by r.david.murray, last changed 2010-07-10 17:19 by michael.foord. This issue is now closed.

Files
File name Uploaded Description Edit
unittest_assertEquals.patch r.david.murray, 2010-07-06 04:02
Messages (2)
msg109365 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-07-06 04:02
When assertEqual is called on a pair of strings, then in Python3 assertMultiLineEqual is called.  This function calls ndiff to display a nicely formatted multiline comparison of the strings, which would make it very easy to spot the differences...if it worked.  However, ndiff does not add newlines where they do not exist, so the output is not correctly formatted when strings without newlines are compared.

Attached is a unit test and patch.

This fix should be backported to 2.7, since assertMultiLineEqual is used there for unicode strings.

Assigning to Michael Foord for review.  Michael, you can assign it back to me if you'd like me to commit it.
msg109869 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-07-10 13:56
Committed revision 82767. (py3k)
Committed revision 82765. (release27-maint)
Fix could be ported to Python 3.1 as a bugfix as well.
History
Date User Action Args
2010-07-10 17:19:42michael.foordsetmessages: - msg109896
2010-07-10 17:19:10michael.foordsetmessages: + msg109896
2010-07-10 13:56:32michael.foordsetstatus: open -> closed
resolution: accepted
messages: + msg109869

stage: patch review -> resolved
2010-07-06 04:02:16r.david.murraycreate