Make test.test_support.catch_warnings more robust as discussed on python-dev. Also add explicit tests for itto test_warnings.
diff --git a/Lib/test/test_py3kwarn.py b/Lib/test/test_py3kwarn.py
index a289cc7..0d01572 100644
--- a/Lib/test/test_py3kwarn.py
+++ b/Lib/test/test_py3kwarn.py
@@ -26,41 +26,30 @@
         with catch_warning() as w:
             safe_exec("True = False")
             self.assertWarning(None, w, expected)
-        with catch_warning() as w:
             safe_exec("False = True")
             self.assertWarning(None, w, expected)
-        with catch_warning() as w:
             try:
                 safe_exec("obj.False = True")
             except NameError: pass
             self.assertWarning(None, w, expected)
-        with catch_warning() as w:
             try:
                 safe_exec("obj.True = False")
             except NameError: pass
             self.assertWarning(None, w, expected)
-        with catch_warning() as w:
             safe_exec("def False(): pass")
             self.assertWarning(None, w, expected)
-        with catch_warning() as w:
             safe_exec("def True(): pass")
             self.assertWarning(None, w, expected)
-        with catch_warning() as w:
             safe_exec("class False: pass")
             self.assertWarning(None, w, expected)
-        with catch_warning() as w:
             safe_exec("class True: pass")
             self.assertWarning(None, w, expected)
-        with catch_warning() as w:
             safe_exec("def f(True=43): pass")
             self.assertWarning(None, w, expected)
-        with catch_warning() as w:
             safe_exec("def f(False=None): pass")
             self.assertWarning(None, w, expected)
-        with catch_warning() as w:
             safe_exec("f(False=True)")
             self.assertWarning(None, w, expected)
-        with catch_warning() as w:
             safe_exec("f(True=1)")
             self.assertWarning(None, w, expected)
 
@@ -69,25 +58,20 @@
         expected = 'type inequality comparisons not supported in 3.x'
         with catch_warning() as w:
             self.assertWarning(int < str, w, expected)
-        with catch_warning() as w:
             self.assertWarning(type < object, w, expected)
 
     def test_object_inequality_comparisons(self):
         expected = 'comparing unequal types not supported in 3.x'
         with catch_warning() as w:
             self.assertWarning(str < [], w, expected)
-        with catch_warning() as w:
             self.assertWarning(object() < (1, 2), w, expected)
 
     def test_dict_inequality_comparisons(self):
         expected = 'dict inequality comparisons not supported in 3.x'
         with catch_warning() as w:
             self.assertWarning({} < {2:3}, w, expected)
-        with catch_warning() as w:
             self.assertWarning({} <= {}, w, expected)
-        with catch_warning() as w:
             self.assertWarning({} > {2:3}, w, expected)
-        with catch_warning() as w:
             self.assertWarning({2:3} >= {}, w, expected)
 
     def test_cell_inequality_comparisons(self):
@@ -100,7 +84,6 @@
         cell1, = f(1).func_closure
         with catch_warning() as w:
             self.assertWarning(cell0 == cell1, w, expected)
-        with catch_warning() as w:
             self.assertWarning(cell0 < cell1, w, expected)
 
     def test_code_inequality_comparisons(self):
@@ -111,11 +94,8 @@
             pass
         with catch_warning() as w:
             self.assertWarning(f.func_code < g.func_code, w, expected)
-        with catch_warning() as w:
             self.assertWarning(f.func_code <= g.func_code, w, expected)
-        with catch_warning() as w:
             self.assertWarning(f.func_code >= g.func_code, w, expected)
-        with catch_warning() as w:
             self.assertWarning(f.func_code > g.func_code, w, expected)
 
     def test_builtin_function_or_method_comparisons(self):
@@ -125,11 +105,8 @@
         meth = {}.get
         with catch_warning() as w:
             self.assertWarning(func < meth, w, expected)
-        with catch_warning() as w:
             self.assertWarning(func > meth, w, expected)
-        with catch_warning() as w:
             self.assertWarning(meth <= func, w, expected)
-        with catch_warning() as w:
             self.assertWarning(meth >= func, w, expected)
 
     def assertWarning(self, _, warning, expected_message):
@@ -142,11 +119,8 @@
 
         with catch_warning() as w:
             self.assertWarning(lst.sort(cmp=cmp), w, expected)
-        with catch_warning() as w:
             self.assertWarning(sorted(lst, cmp=cmp), w, expected)
-        with catch_warning() as w:
             self.assertWarning(lst.sort(cmp), w, expected)
-        with catch_warning() as w:
             self.assertWarning(sorted(lst, cmp), w, expected)
 
     def test_sys_exc_clear(self):
@@ -229,7 +203,7 @@
         """Make sure the specified module, when imported, raises a
         DeprecationWarning and specifies itself in the message."""
         with CleanImport(module_name):
-            with catch_warning(record=False) as w:
+            with catch_warning(record=False):
                 warnings.filterwarnings("error", ".+ removed",
                                         DeprecationWarning)
                 try:
@@ -290,7 +264,7 @@
 
 
 def test_main():
-    with catch_warning(record=True):
+    with catch_warning():
         warnings.simplefilter("always")
         run_unittest(TestPy3KWarnings,
                      TestStdlibRemovals)