summaryrefslogtreecommitdiff
path: root/Lib/test/test_structmembers.py
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2007-04-03 18:33:29 +0000
committerWalter Dörwald <walter@livinglogic.de>2007-04-03 18:33:29 +0000
commite477318e80e745f7aa5cf9abea6b81fee9db6e99 (patch)
tree1dd1016d6753ccad4fd4f64d684667ee1ea06271 /Lib/test/test_structmembers.py
parent2ee7bc0df30f1a30a7ce6f8f9d313b4750c03316 (diff)
downloadcpython-e477318e80e745f7aa5cf9abea6b81fee9db6e99.tar.gz
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.
Diffstat (limited to 'Lib/test/test_structmembers.py')
-rw-r--r--Lib/test/test_structmembers.py39
1 files changed, 22 insertions, 17 deletions
diff --git a/Lib/test/test_structmembers.py b/Lib/test/test_structmembers.py
index 5dc21759b8..33fc776ace 100644
--- a/Lib/test/test_structmembers.py
+++ b/Lib/test/test_structmembers.py
@@ -4,7 +4,7 @@ from _testcapi import test_structmembersType, \
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 @@ class ReadWriteTests(unittest.TestCase):
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)