Opened 7 years ago

Closed 7 years ago

#2893 enhancement closed fixed (fixed)

assertEqual is hard to read.

Reported by: jml Owned by:
Priority: highest Milestone:
Component: trial Keywords:
Cc: Branch: branches/assertEqual-2893
(diff, github, buildbot, log)
Author: Launchpad Bug:

Description

We should do what bzrlib does.

Change History (8)

comment:1 Changed 7 years ago by jml

  • Component changed from core to trial
  • Owner changed from glyph to jml

comment:2 Changed 7 years ago by jml

  • Branch set to branches/assertEqual-2893

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

comment:3 Changed 7 years ago by jml

  • Keywords review added
  • Owner changed from jml to radix
  • Priority changed from normal to highest

comment:4 Changed 7 years ago by exarkun

  • Keywords review removed
  • Owner changed from radix to jml
  • 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 7 years ago by jml

  • Keywords review added
  • Owner changed from jml to exarkun

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

Added docstring and a new test for msg=None.

comment:6 Changed 7 years ago by exarkun

  • Keywords review removed
  • Owner changed from exarkun to jml

Great, please merge.

comment:7 Changed 7 years ago by jml

  • Resolution set to fixed
  • Status changed from new to closed

(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 3 years ago by <automation>

  • Owner jml deleted
Note: See TracTickets for help on using tickets.