Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better failure messages for unittest assertions #49913

Closed
voidspace opened this issue Apr 2, 2009 · 3 comments
Closed

Better failure messages for unittest assertions #49913

voidspace opened this issue Apr 2, 2009 · 3 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@voidspace
Copy link
Contributor

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']

    @voidspace
    Copy link
    Contributor Author

    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.

    @voidspace voidspace added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Apr 2, 2009
    @voidspace
    Copy link
    Contributor Author

    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

    @voidspace
    Copy link
    Contributor Author

    Updated patch with better docstring for _formatMessage and docs.

    Patch reviewed by Brett Cannon so will commit.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant