diff options
| author | Nick Coghlan <ncoghlan@gmail.com> | 2008-09-11 12:11:06 (GMT) |
|---|---|---|
| committer | Nick Coghlan <ncoghlan@gmail.com> | 2008-09-11 12:11:06 (GMT) |
| commit | d2e09383624944add0e670b857c572129d56988e (patch) | |
| tree | f77e6631636c1d33d9bd5cf1e3e905c571ac9cd9 /Lib/test/test_import.py | |
| parent | 9fa5a2828c8007dfb678b883d65aecac93e995e4 (diff) | |
| download | cpython-d2e09383624944add0e670b857c572129d56988e.zip cpython-d2e09383624944add0e670b857c572129d56988e.tar.gz cpython-d2e09383624944add0e670b857c572129d56988e.tar.bz2 | |
Issue #3781: Final cleanup of warnings.catch_warnings and its usage in the test suite. Closes issue w.r.t. 2.6 (R: Brett Cannon)
Diffstat (limited to 'Lib/test/test_import.py')
| -rw-r--r-- | Lib/test/test_import.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index 644a473..13e8cc3 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -5,7 +5,7 @@ import shutil import sys import py_compile import warnings -from test.test_support import unlink, TESTFN, unload, run_unittest +from test.test_support import unlink, TESTFN, unload, run_unittest, check_warnings def remove_files(name): @@ -279,17 +279,17 @@ class RelativeImport(unittest.TestCase): check_relative() # Check relative fails with only __package__ wrong ns = dict(__package__='foo', __name__='test.notarealmodule') - with warnings.catch_warnings(record=True) as w: + with check_warnings() as w: check_absolute() - self.assert_('foo' in str(w[-1].message)) - self.assertEqual(w[-1].category, RuntimeWarning) + self.assert_('foo' in str(w.message)) + self.assertEqual(w.category, RuntimeWarning) self.assertRaises(SystemError, check_relative) # Check relative fails with __package__ and __name__ wrong ns = dict(__package__='foo', __name__='notarealpkg.notarealmodule') - with warnings.catch_warnings(record=True) as w: + with check_warnings() as w: check_absolute() - self.assert_('foo' in str(w[-1].message)) - self.assertEqual(w[-1].category, RuntimeWarning) + self.assert_('foo' in str(w.message)) + self.assertEqual(w.category, RuntimeWarning) self.assertRaises(SystemError, check_relative) # Check both fail with package set to a non-string ns = dict(__package__=object()) |
