Implement a contextmanager test.test_support.catch_warning that can
be used to catch the last warning issued by the warning framework.

Change test_warnings.py and test_structmembers.py to use this
new contextmanager.
diff --git a/Lib/test/test_structmembers.py b/Lib/test/test_structmembers.py
index 5dc2175..33fc776 100644
--- a/Lib/test/test_structmembers.py
+++ b/Lib/test/test_structmembers.py
@@ -4,7 +4,7 @@
     INT_MAX, INT_MIN, UINT_MAX, \
     LONG_MAX, LONG_MIN, ULONG_MAX
 
-import warnings, exceptions, unittest, test.test_warnings
+import warnings, exceptions, unittest
 from test import test_support
 
 ts=test_structmembersType(1,2,3,4,5,6,7,8,9.99999,10.1010101010)
@@ -39,34 +39,39 @@
         ts.T_ULONG=ULONG_MAX
         self.assertEquals(ts.T_ULONG, ULONG_MAX)
 
-class TestWarnings(test.test_warnings.CatchWarningTest):
-    def has_warned(self):
-        self.assertEqual(test.test_warnings.msg.category,
-                         exceptions.RuntimeWarning.__name__)
+class TestWarnings(unittest.TestCase):
+    def has_warned(self, w):
+        self.assert_(w.category is RuntimeWarning)
 
     def test_byte_max(self):
-        ts.T_BYTE=CHAR_MAX+1
-        self.has_warned()
+        with test_support.catch_warning() as w:
+            ts.T_BYTE=CHAR_MAX+1
+            self.has_warned(w)
 
     def test_byte_min(self):
-        ts.T_BYTE=CHAR_MIN-1
-        self.has_warned()
+        with test_support.catch_warning() as w:
+            ts.T_BYTE=CHAR_MIN-1
+            self.has_warned(w)
 
     def test_ubyte_max(self):
-        ts.T_UBYTE=UCHAR_MAX+1
-        self.has_warned()
+        with test_support.catch_warning() as w:
+            ts.T_UBYTE=UCHAR_MAX+1
+            self.has_warned(w)
 
     def test_short_max(self):
-        ts.T_SHORT=SHRT_MAX+1
-        self.has_warned()
+        with test_support.catch_warning() as w:
+            ts.T_SHORT=SHRT_MAX+1
+            self.has_warned(w)
 
     def test_short_min(self):
-        ts.T_SHORT=SHRT_MIN-1
-        self.has_warned()
+        with test_support.catch_warning() as w:
+            ts.T_SHORT=SHRT_MIN-1
+            self.has_warned(w)
 
     def test_ushort_max(self):
-        ts.T_USHORT=USHRT_MAX+1
-        self.has_warned()
+        with test_support.catch_warning() as w:
+            ts.T_USHORT=USHRT_MAX+1
+            self.has_warned(w)