Add TestCase.assertWarnings(), to help test against multiple warnings.
Review Request #12723 — Created Nov. 14, 2022 and submitted
TestCase.assertWarnings(), which takes a list of
dictionaries representing warnings and compares against them. Like our
assertWarns(), it can compare against classes and then
optionally messages. This can be extended for other capabilities, like
native regex matching, if needed.
This can be used both for asserting that there are warnings (by
specifying one or more items in the list) or no warnings (by specifying
an empty list).
assertNoWarnings()now wraps this,
helping us manage just one set of logic.
TestCase.assertWarns()is pending a deprecation phase It's
incompatible with Python's own version of
assertWarns(), and as such
we should probably move off of it. For now, it's not documented as
deprecated, but it does have a big comment about it. We'll want to
figure that out at some point, but not today.
All unit tests pass.
Tested the multiple warning matching in an in-progress change.