This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Better failure messages for unittest assertions
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: michael.foord, michael.foord
Priority: normal Keywords: patch

Created on 2009-04-02 01:58 by michael.foord, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
unittest-messages.diff michael.foord, 2009-04-02 01:58
unittest-messages.diff michael.foord, 2009-04-02 03:12
Messages (3)
msg85136 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-04-02 01:58
Patch for unittest on trunk.

It provides better default failure messages for assertTrue and
assertFalse (current is "AssertionError: None").

It also provides a new class attribute for TestCase: longMessage

This defaults to False. If set to True, passing in an explicit custom
message does *not* override the helpful default failure message in
asserts which tell you which objects were involved in the failure.

Even if set to True or False in a TestCase then longMessage can still be
overridden in individual tests by setting an instance attribute.



Needs docs.

Could longMessage default to True in 3.1.
msg85137 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-04-02 02:02
Reviewers: ,

Description:
Patch for unittest on trunk.

It provides better default failure messages for assertTrue and
assertFalse (current is "AssertionError: None").

It also provides a new class attribute for TestCase: longMessage

This defaults to False. If set to True, passing in an explicit custom
message does *not* override the helpful default failure message in
asserts which tell you which objects were involved in the failure.

Even if set to True or False in a TestCase then longMessage can still be
overridden in individual tests by setting an instance attribute.

Needs docs.

Could longMessage default to True in 3.1?

Please review this at http://codereview.appspot.com/32102

Affected files:
   Lib/test/test_unittest.py
   Lib/unittest.py
   Misc/NEWS
msg85150 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-04-02 03:12
Updated patch with better docstring for _formatMessage and docs.

Patch reviewed by Brett Cannon so will commit.
History
Date User Action Args
2022-04-11 14:56:47adminsetgithub: 49913
2009-04-02 03:22:52michael.foordsetstatus: open -> closed
resolution: accepted
2009-04-02 03:12:42michael.foordsetfiles: + unittest-messages.diff

messages: + msg85150
2009-04-02 02:02:23fuzzymansetnosy: + fuzzyman
messages: + msg85137
2009-04-02 01:58:39michael.foordcreate