Add TestCase.assertWarnings(), to help test against multiple warnings.

Review Request #12723 — Created Nov. 14, 2022 and submitted

Information

Djblets
release-3.x

Reviewers

This introduces TestCase.assertWarnings(), which takes a list of
dictionaries representing warnings and compares against them. Like our
version of 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).

Both TestCase.assertWarns() and 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.

Summary ID
Add TestCase.assertWarnings(), to help test against multiple warnings.
This introduces `TestCase.assertWarnings()`, which takes a list of dictionaries representing warnings and compares against them. Like our version of `assertWarns()`, it can compare against classes and then optionally messages. 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). `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.
28533b7c554ddd350a4fe6f558fb2c9febc6481a
david
  1. Ship It!
  2. 
      
maubin
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-3.x (db0cefd)
Loading...