Merged revisions 78769,79049 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78769 | florent.xicluna | 2010-03-07 21:14:12 +0200 (Sun, 07 Mar 2010) | 2 lines

  Refresh the documentation for the test.test_support module.
........
  r79049 | florent.xicluna | 2010-03-18 21:51:47 +0200 (Thu, 18 Mar 2010) | 2 lines

  #8155: Preserve backward compatibility for test_support.check_warnings().  Add regression tests.
........
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index fab8086..b1e2010 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -600,19 +600,33 @@
     def test_check_warnings(self):
         # Explicit tests for the test_support convenience wrapper
         wmod = self.module
-        if wmod is sys.modules['warnings']:
-            with test_support.check_warnings() as w:
-                self.assertEqual(w.warnings, [])
-                wmod.simplefilter("always")
-                wmod.warn("foo")
-                self.assertEqual(str(w.message), "foo")
-                wmod.warn("bar")
-                self.assertEqual(str(w.message), "bar")
-                self.assertEqual(str(w.warnings[0].message), "foo")
-                self.assertEqual(str(w.warnings[1].message), "bar")
-                w.reset()
-                self.assertEqual(w.warnings, [])
+        if wmod is not sys.modules['warnings']:
+            return
+        with test_support.check_warnings(quiet=False) as w:
+            self.assertEqual(w.warnings, [])
+            wmod.simplefilter("always")
+            wmod.warn("foo")
+            self.assertEqual(str(w.message), "foo")
+            wmod.warn("bar")
+            self.assertEqual(str(w.message), "bar")
+            self.assertEqual(str(w.warnings[0].message), "foo")
+            self.assertEqual(str(w.warnings[1].message), "bar")
+            w.reset()
+            self.assertEqual(w.warnings, [])
 
+        with test_support.check_warnings():
+            # defaults to quiet=True without argument
+            pass
+        with test_support.check_warnings(('foo', UserWarning)):
+            wmod.warn("foo")
+
+        with self.assertRaises(AssertionError):
+            with test_support.check_warnings(('', RuntimeWarning)):
+                # defaults to quiet=False with argument
+                pass
+        with self.assertRaises(AssertionError):
+            with test_support.check_warnings(('foo', RuntimeWarning)):
+                wmod.warn("foo")
 
 
 class CCatchWarningTests(CatchWarningTests):