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

Provide unittest.TestCase.assertNotRegexpMatches #52286

Closed
voidspace opened this issue Mar 2, 2010 · 6 comments
Closed

Provide unittest.TestCase.assertNotRegexpMatches #52286

voidspace opened this issue Mar 2, 2010 · 6 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@voidspace
Copy link
Contributor

BPO 8038
Nosy @ezio-melotti, @voidspace
Files
  • assertNotRegexpMatches.patch: patch with assertNotRegexpMatches.
  • 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 = 'https://github.com/voidspace'
    closed_at = <Date 2010-05-08.16:42:16.243>
    created_at = <Date 2010-03-02.13:57:45.080>
    labels = ['type-bug', 'library']
    title = 'Provide unittest.TestCase.assertNotRegexpMatches'
    updated_at = <Date 2010-05-08.16:42:16.242>
    user = 'https://github.com/voidspace'

    bugs.python.org fields:

    activity = <Date 2010-05-08.16:42:16.242>
    actor = 'michael.foord'
    assignee = 'michael.foord'
    closed = True
    closed_date = <Date 2010-05-08.16:42:16.243>
    closer = 'michael.foord'
    components = ['Library (Lib)']
    creation = <Date 2010-03-02.13:57:45.080>
    creator = 'michael.foord'
    dependencies = []
    files = ['16498']
    hgrepos = []
    issue_num = 8038
    keywords = ['patch']
    message_count = 6.0
    messages = ['100291', '100292', '100616', '100664', '102211', '105313']
    nosy_count = 3.0
    nosy_names = ['ezio.melotti', 'michael.foord', 'Ryszard.Szopa']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue8038'
    versions = ['Python 2.7', 'Python 3.2']

    @voidspace
    Copy link
    Contributor Author

    Originally reported as a bug against unittest2: http://code.google.com/p/unittest-ext/issues/detail?id=3

    There are some assert* methods that don't have their assertNot*
    counterparts. There's assertDictEqual, assertSequenceEqual,
    assertRegexpMatches, but no assertDictNotEqual, assertSequenceNotEqual,
    assertRegexpNotMatches, for example.

    They should be present for the sake of completeness (I don't like to have to look into the docs to check if a method has a negative counterpart), but also because they ask for a custom output. For example, the error accompanying assertRegexpNotMatches could show the matching part of the text, which is the part that really interests me. assert_(re.match(...)) will only tell me that None is not true...

    @voidspace voidspace self-assigned this Mar 2, 2010
    @voidspace voidspace added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Mar 2, 2010
    @voidspace
    Copy link
    Contributor Author

    Should there be a 'discussion' stage for the tracker?

    This isn't *really* at the 'test needed' stage, I'm not 100% convinced we should add all these extra methods just 'for the sake of completeness' - but if they are *needed* they should be added.

    @RyszardSzopa
    Copy link
    Mannequin

    RyszardSzopa mannequin commented Mar 7, 2010

    Hi,

    I am the original reporter of the bug. Please forgive me if this is not the place for discussing the issue.

    I've thought about it, and stuff like assertDictNotEqual or assertSequenceNotEqual aren't really necessary - it is much easier (and shorter) to use assertNotEqual, and there's no need for any special formatting needed to say that something is equal when it shouldn't.

    This is not the case for assertNotRegexpMatches, though. assertNot(re.match(...)) tells me only that False is not True. I'd like it to say *how* the text matches the regex (the matching part that is). (Sorry for repeating myself, I try to be clearer this time.)

    So, this issue could be renamed to "Implement assertNotRegexpMatches."

    @voidspace voidspace changed the title Not all the new assert* unittest.TestCase methods have negative (not) equivalents Provide unittest.TestCase.assertNotRegexpMatches Mar 7, 2010
    @RyszardSzopa
    Copy link
    Mannequin

    RyszardSzopa mannequin commented Mar 8, 2010

    Here's the patch against unittest2 that implements assertNotRegexpMatches.

    @voidspace
    Copy link
    Contributor Author

    Committed revision 79632.

    @voidspace
    Copy link
    Contributor Author

    Docstrings committed revision 80990.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    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