Skip to content

Better failure messages for unittest assertions #49913

Closed

Description

@voidspace
BPO 5663
Nosy @voidspace, @voidspace
Files
  • unittest-messages.diff
  • unittest-messages.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2009-04-02.03:22:52.286>
    created_at = <Date 2009-04-02.01:58:39.178>
    labels = ['type-bug', 'library']
    title = 'Better failure messages for unittest assertions'
    updated_at = <Date 2009-04-02.03:22:52.023>
    user = 'https://github.com/voidspace'

    bugs.python.org fields:

    activity = <Date 2009-04-02.03:22:52.023>
    actor = 'michael.foord'
    assignee = 'none'
    closed = True
    closed_date = <Date 2009-04-02.03:22:52.286>
    closer = 'michael.foord'
    components = ['Library (Lib)']
    creation = <Date 2009-04-02.01:58:39.178>
    creator = 'michael.foord'
    dependencies = []
    files = ['13567', '13568']
    hgrepos = []
    issue_num = 5663
    keywords = ['patch']
    message_count = 3.0
    messages = ['85136', '85137', '85150']
    nosy_count = 2.0
    nosy_names = ['michael.foord', 'michael.foord']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue5663'
    versions = ['Python 2.7']

    Activity

    1. voidspace commented on Apr 2, 2009

      @voidspace
      ContributorAuthor

      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.

    2. added
      stdlib
      type-bug
      on Apr 2, 2009
    3. voidspace commented on Apr 2, 2009

      @voidspace
      ContributorAuthor

      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

    4. voidspace commented on Apr 2, 2009

      @voidspace
      ContributorAuthor

      Updated patch with better docstring for _formatMessage and docs.

      Patch reviewed by Brett Cannon so will commit.

    5. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibtype-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions