summaryrefslogtreecommitdiffstats
path: root/Lib/test/support.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-10-29 11:54:03 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-10-29 11:54:03 (GMT)
commit31e08a4df6f0c4c1f6adaf0aa4fc1f6632815492 (patch)
tree0d7b12ed99d3924688c69b7bad1476a5c7bcf82a /Lib/test/support.py
parenta0d2f4def9c0584e615c7531388614127f517075 (diff)
downloadcpython-31e08a4df6f0c4c1f6adaf0aa4fc1f6632815492.zip
cpython-31e08a4df6f0c4c1f6adaf0aa4fc1f6632815492.tar.gz
cpython-31e08a4df6f0c4c1f6adaf0aa4fc1f6632815492.tar.bz2
Make check_warnings error messages more informative
Diffstat (limited to 'Lib/test/support.py')
-rw-r--r--Lib/test/support.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py
index e48f2b3..31528a9 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])