Align 'assertEqual' output

Bug #879339 reported by John A Meinel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
testtools
Fix Released
Wishlist
Jonathan Lange

Bug Description

When using assertEqual on content that is a reasonable sized string, it is really nice to have the strings lined up vertically, to make it clear what bit does not match. Right now the output is:
reference = 'd\x00\x00\x000{"client_version": "0.0.1.dev.0", "request": "name"}d\x00\x00\x00\x08{"a": 1}'
actual = 'd\x00\x00\x004{"client_version": "0.0.1.dev.0", "request": "name"}d\x00\x00\x00\x08{"a": 1}'

Which makes it hard to see what byte is actually different. If you changed it to:
reference = 'd\x00\x00\x000{"client_version": "0.0.1.dev.0", "request": "name"}d\x00\x00\x00\x08{"a": 1}'
actual = 'd\x00\x00\x004{"client_version": "0.0.1.dev.0", "request": "name"}d\x00\x00\x00\x08{"a": 1}'

(You need a fixed width font, and not Launchpad's rendering of the above)

Then the columns match up and it is easy to detect the one character which is different.

Related branches

Revision history for this message
Robert Collins (lifeless) wrote :

What John means is 'add some spaces after 'actual' to pad it the same length as reference.

Changed in testtools:
status: New → Triaged
importance: Undecided → Wishlist
Jonathan Lange (jml)
Changed in testtools:
status: Triaged → In Progress
assignee: nobody → Jonathan Lange (jml)
Jonathan Lange (jml)
Changed in testtools:
status: In Progress → Fix Committed
milestone: none → next
Jonathan Lange (jml)
Changed in testtools:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.