Issue 9174: unittest assertEqual error output sub-optimal for single strings (original) (raw)

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.