[Python-checkins] r85925 - python/branches/py3k/Lib/test/support.py

antoine.pitrou python-checkins at python.org
Fri Oct 29 13:54:03 CEST 2010


Author: antoine.pitrou
Date: Fri Oct 29 13:54:03 2010
New Revision: 85925

Log:
Make check_warnings error messages more informative



Modified:
   python/branches/py3k/Lib/test/support.py

Modified: python/branches/py3k/Lib/test/support.py
==============================================================================
--- python/branches/py3k/Lib/test/support.py	(original)
+++ python/branches/py3k/Lib/test/support.py	Fri Oct 29 13:54:03 2010
@@ -596,22 +596,22 @@
         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])


More information about the Python-checkins mailing list