From: Antoine Pitrou Date: Fri, 29 Oct 2010 11:54:03 +0000 (+0000) Subject: Make check_warnings error messages more informative X-Git-Tag: v3.2a4~297 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=31e08a4df6f0c4c1f6adaf0aa4fc1f6632815492;p=python Make check_warnings error messages more informative --- diff --git a/Lib/test/support.py b/Lib/test/support.py index e48f2b313c..31528a9492 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -596,22 +596,22 @@ def _filterwarnings(filters, quiet=False): sys.modules['warnings'].simplefilter("always") yield WarningsRecorder(w) # Filter the recorded warnings - reraise = [warning.message for warning in w] + reraise = list(w) missing = [] for msg, cat in filters: seen = False - for exc in reraise[:]: - message = str(exc) + for w in reraise[:]: + warning = w.message # Filter out the matching messages - if (re.match(msg, message, re.I) and - issubclass(exc.__class__, cat)): + if (re.match(msg, str(warning), re.I) and + issubclass(warning.__class__, cat)): seen = True - reraise.remove(exc) + reraise.remove(w) if not seen and not quiet: # This filter caught nothing missing.append((msg, cat.__name__)) if reraise: - raise AssertionError("unhandled warning %r" % reraise[0]) + raise AssertionError("unhandled warning %s" % reraise[0]) if missing: raise AssertionError("filter (%r, %s) did not catch any warning" % missing[0])