diff options
Diffstat (limited to 'test/lib/testing.py')
-rw-r--r-- | test/lib/testing.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/lib/testing.py b/test/lib/testing.py index 00b65c6e3..8f4838d0a 100644 --- a/test/lib/testing.py +++ b/test/lib/testing.py @@ -387,6 +387,18 @@ def emits_warning_on(db, *warnings): return function_named(maybe, fn.__name__) return decorate +def assert_warnings(fn, warnings): + """Assert that each of the given warnings are emitted by fn.""" + + orig_warn = util.warn + def capture_warnings(*args, **kw): + orig_warn(*args, **kw) + popwarn = warnings.pop(0) + eq_(args[0], popwarn) + util.warn = util.langhelpers.warn = capture_warnings + + return emits_warning()(fn)() + def uses_deprecated(*messages): """Mark a test as immune from fatal deprecation warnings. |