Commit d815d357 authored by Walter Dörwald's avatar Walter Dörwald

Move the functionality for catching warnings in test_warnings.py into a separate

class to that reusing the functionality in test_structmembers.py doesn't rerun
the tests from test_warnings.py.
parent c3a35e19
...@@ -39,7 +39,7 @@ class ReadWriteTests(unittest.TestCase): ...@@ -39,7 +39,7 @@ class ReadWriteTests(unittest.TestCase):
ts.T_ULONG=ULONG_MAX ts.T_ULONG=ULONG_MAX
self.assertEquals(ts.T_ULONG, ULONG_MAX) self.assertEquals(ts.T_ULONG, ULONG_MAX)
class TestWarnings(test.test_warnings.TestModule): class TestWarnings(test.test_warnings.CatchWarningTest):
def has_warned(self): def has_warned(self):
self.assertEqual(test.test_warnings.msg.category, self.assertEqual(test.test_warnings.msg.category,
exceptions.RuntimeWarning.__name__) exceptions.RuntimeWarning.__name__)
......
...@@ -20,7 +20,7 @@ def showwarning(message, category, filename, lineno, file=None): ...@@ -20,7 +20,7 @@ def showwarning(message, category, filename, lineno, file=None):
msg.filename = os.path.basename(filename) msg.filename = os.path.basename(filename)
msg.lineno = lineno msg.lineno = lineno
class TestModule(unittest.TestCase): class CatchWarningTest(unittest.TestCase):
def setUp(self): def setUp(self):
global msg global msg
...@@ -35,6 +35,8 @@ class TestModule(unittest.TestCase): ...@@ -35,6 +35,8 @@ class TestModule(unittest.TestCase):
warnings.filters = self._filters[:] warnings.filters = self._filters[:]
warnings.showwarning = self._showwarning warnings.showwarning = self._showwarning
class TestModule(CatchWarningTest):
def test_warn_default_category(self): def test_warn_default_category(self):
for i in range(4): for i in range(4):
text = 'multi %d' %i # Different text on each call text = 'multi %d' %i # Different text on each call
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment