Opened 9 years ago

Closed 9 years ago

#2893 enhancement closed fixed (fixed)

assertEqual is hard to read.

Reported by: Jonathan Lange Owned by:
Priority: highest Milestone:
Component: trial Keywords:
Cc: Branch: branches/assertEqual-2893
branch-diff, diff-cov, branch-cov, buildbot
Author:

Description

We should do what bzrlib does.

Change History (8)

comment:1 Changed 9 years ago by Jonathan Lange

Component: coretrial
Owner: changed from Glyph to Jonathan Lange

comment:2 Changed 9 years ago by Jonathan Lange

Branch: branches/assertEqual-2893

(In [21722]) Branching to 'assertEqual-2893'

comment:3 Changed 9 years ago by Jonathan Lange

Keywords: review added
Owner: changed from Jonathan Lange to radix
Priority: normalhighest

comment:4 Changed 9 years ago by Jean-Paul Calderone

Keywords: review removed
Owner: changed from radix to Jonathan Lange
  • in twisted/trial/test/test_assertions.py:
    • The new test method TestAssertions.test_failUnlessEqualMessage has no docstring.
    • The modified method _testUnequalPair on the same class also has no docstring.
  • in twisted/trial/unittest.py:
    • The docstring of failUnlessEqual used to say if msg is None, .... But if None is passed for msg now, the output is a bit ugly:
      twisted.trial.unittest.FailTest: Nonenot equal:
      
      maybe this case needs some test coverage?

The change is definitely an improvement. Something to think about for a wider scope of improvement (ie, beyond the scope of this ticket) might be to leave this formatting up to the reporter and just construct the exception with the objects it needs (making them publically available on the exception).

comment:5 Changed 9 years ago by Jonathan Lange

Keywords: review added
Owner: changed from Jonathan Lange to Jean-Paul Calderone

Definitely agree regarding wider scope, but that's a research project.

Added docstring and a new test for msg=None.

comment:6 Changed 9 years ago by Jean-Paul Calderone

Keywords: review removed
Owner: changed from Jean-Paul Calderone to Jonathan Lange

Great, please merge.

comment:7 Changed 9 years ago by Jonathan Lange

Resolution: fixed
Status: newclosed

(In [21730]) Provide a more readable error message when assertEqual fails.

  • Author: jml
  • Reviewer: exarkun
  • Fixes #2893

assertEqual's error message now always includes the objects being compared. In addition, it displays these objects on separate lines and formats them with pprint.pformat.

comment:8 Changed 6 years ago by <automation>

Owner: Jonathan Lange deleted
Note: See TracTickets for help on using tickets.