Ticket #2893 (closed enhancement: fixed )

Opened 2 years ago

Last modified 2 years ago

assertEqual is hard to read.

Reported by: jml Assigned to: jml
Type: enhancement Priority: highest
Milestone: Component: trial
Keywords: Cc:
Branch: branches/assertEqual-2893 Author:
Launchpad Bug:

Description

We should do what bzrlib does.

Attachments

Change History

  2007-11-13 02:47:50+00:00 changed by jml

  • owner changed from glyph to jml
  • component changed from core to trial

  2007-11-13 02:48:57+00:00 changed by jml

  • branch set to branches/assertEqual-2893

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

  2007-11-13 03:27:57+00:00 changed by jml

  • keywords set to review
  • owner changed from jml to radix
  • priority changed from normal to highest

  2007-11-13 14:02:57+00:00 changed by exarkun

  • keywords deleted
  • 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).

  2007-11-13 14:35:25+00:00 changed by jml

  • keywords set to review
  • 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.

  2007-11-13 15:00:04+00:00 changed by exarkun

  • keywords deleted
  • owner changed from exarkun to jml

Great, please merge.

  2007-11-13 15:06:44+00:00 changed by jml

  • status changed from new to closed
  • resolution set to fixed

(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.

Note: See TracTickets for help on using tickets.