[issue24922] assertWarnsRegex doesn't allow multiple warning messages

Rose Ames report at bugs.python.org
Mon Jan 18 17:58:18 EST 2016


Rose Ames added the comment:

Would this mean that we expect any one of the warnings to be raised, or all of them?  If it's one, the example you give would be equivalent to:

    self.assertWarnsRegex(UserWarning, "^W100[01]")

Matching all of the warnings seems more interesting, but I'm not sure how to handle the context manager attributes.  For instance, right now you can do:

    with self.assertWarnsRegex(FooWarning, "Bar") as cm:
        blah()
    self.assertEquals(cm.lineno, 1000)

Would lineno and filename become lists?  It seems kind of ugly.  What's the advantage over simply testing for each warning separately?

----------
nosy: +superluser

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24922>
_______________________________________


More information about the Python-bugs-list mailing list