diff options
| author | Konrad Delong <konryd@gmail.com> | 2010-08-15 00:18:54 +0200 |
|---|---|---|
| committer | Konrad Delong <konryd@gmail.com> | 2010-08-15 00:18:54 +0200 |
| commit | dff6f3c4538d145bb39c3f36a77eb025a0b792a2 (patch) | |
| tree | e9934b37507067dd1ca81ab543a405321b7aaa0f /src/distutils2/tests/test_test.py | |
| parent | 9dbb076c4e6e664343f0dcf6c7bd822905048e45 (diff) | |
| download | disutils2-dff6f3c4538d145bb39c3f36a77eb025a0b792a2.tar.gz | |
even better warnings test
Diffstat (limited to 'src/distutils2/tests/test_test.py')
| -rw-r--r-- | src/distutils2/tests/test_test.py | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/distutils2/tests/test_test.py b/src/distutils2/tests/test_test.py index 616d5c0..ab18ef6 100644 --- a/src/distutils2/tests/test_test.py +++ b/src/distutils2/tests/test_test.py @@ -8,7 +8,7 @@ import warnings from copy import copy from os.path import join from StringIO import StringIO -from distutils2.tests.support import unittest, LoggingSilencer, TempdirManager +from distutils2.tests.support import unittest, WarningsCatcher, TempdirManager from distutils2.command.test import test from distutils2.dist import Distribution @@ -63,6 +63,7 @@ def with_ut_isolated(func): return wrapper class TestTest(TempdirManager, + WarningsCatcher, unittest.TestCase): def setUp(self): @@ -123,20 +124,10 @@ class TestTest(TempdirManager, def test_checks_requires(self): dist = Distribution() cmd = test(dist) - record = [] - orig_showwarning = warnings.showwarning - def record_showwarning(*args): - record.append(args) - return orig_showwarning(*args) - try: - warnings.showwarning = record_showwarning - cmd.tests_require = ['ohno_ohno-impossible_1234-name_stop-that!'] - cmd.ensure_finalized() - self.assertEqual(1, len(record)) - warning = record[0] - self.assertIs(warning[1], RuntimeWarning) - finally: - warnings.showwarning = orig_showwarning + cmd.tests_require = ['ohno_ohno-impossible_1234-name_stop-that!'] + cmd.ensure_finalized() + self.assertEqual(1, len(self.warnings)) + self.assertIs(self.warnings[0]["category"], RuntimeWarning) def test_custom_runner(self): dist = Distribution() |
