Add TestCase.assertWarnings(), to help test against multiple warnings.
Review Request #12723 — Created Nov. 14, 2022 and submitted
This introduces
TestCase.assertWarnings()
, which takes a list of
dictionaries representing warnings and compares against them. Like our
version ofassertWarns()
, 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).Both
TestCase.assertWarns()
andassertNoWarnings()
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 ofassertWarns()
, 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.
Summary | ID |
---|---|
28533b7c554ddd350a4fe6f558fb2c9febc6481a |