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

voidspace opened this issue Mar 2, 2010 · 6 comments

Provide unittest.TestCase.assertNotRegexpMatches #52286

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


Copy link

BPO 8038
Nosy @ezio-melotti, @voidspace
  • 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 = ''
    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 = '' 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 = ''
    versions = ['Python 2.7', 'Python 3.2']

    Copy link
    Contributor Author

    Originally reported as a bug against unittest2:

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

    Copy link

    RyszardSzopa mannequin commented Mar 7, 2010


    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
    Copy link

    RyszardSzopa mannequin commented Mar 8, 2010

    Here's the patch against unittest2 that implements assertNotRegexpMatches.

    Copy link
    Contributor Author

    Committed revision 79632.

    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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    None yet

    No branches or pull requests

    1 participant