diff options
| author | Florent Xicluna <florent.xicluna@gmail.com> | 2010-03-31 22:01:03 (GMT) |
|---|---|---|
| committer | Florent Xicluna <florent.xicluna@gmail.com> | 2010-03-31 22:01:03 (GMT) |
| commit | 6257a7bbb2660ae75c44f2e71d7ac2ce73900f74 (patch) | |
| tree | 6f010065c95f2d5617f56e07ba2628be21cf9d7a /Lib/test/test_coercion.py | |
| parent | ad5983364966b49c277b495112ae41c6ae2d01ed (diff) | |
| download | cpython-6257a7bbb2660ae75c44f2e71d7ac2ce73900f74.zip cpython-6257a7bbb2660ae75c44f2e71d7ac2ce73900f74.tar.gz cpython-6257a7bbb2660ae75c44f2e71d7ac2ce73900f74.tar.bz2 | |
Replace catch_warnings with check_warnings when it makes sense. Use assertRaises context manager to simplify some tests.
Diffstat (limited to 'Lib/test/test_coercion.py')
| -rw-r--r-- | Lib/test/test_coercion.py | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/Lib/test/test_coercion.py b/Lib/test/test_coercion.py index 34eb19e..8a74b51 100644 --- a/Lib/test/test_coercion.py +++ b/Lib/test/test_coercion.py @@ -1,7 +1,6 @@ import copy -import warnings import unittest -from test.test_support import run_unittest, TestFailed +from test.test_support import run_unittest, TestFailed, check_warnings # Fake a number that implements numeric methods through __coerce__ class CoerceNumber: @@ -223,12 +222,6 @@ def process_infix_results(): infix_results[key] = res -with warnings.catch_warnings(): - warnings.filterwarnings("ignore", "classic int division", - DeprecationWarning) - process_infix_results() -# now infix_results has two lists of results for every pairing. - prefix_binops = [ 'divmod' ] prefix_results = [ [(1,0), (1L,0L), (0.0,2.0), ((1+0j),0j), TE, TE, TE, TE, (1,0)], @@ -339,11 +332,13 @@ class CoercionTest(unittest.TestCase): raise exc def test_main(): - with warnings.catch_warnings(): - warnings.filterwarnings("ignore", "complex divmod.., // and % " - "are deprecated", DeprecationWarning) - warnings.filterwarnings("ignore", "classic (int|long) division", - DeprecationWarning) + with check_warnings(("complex divmod.., // and % are deprecated", + DeprecationWarning), + ("classic (int|long) division", DeprecationWarning), + quiet=True): + process_infix_results() + # now infix_results has two lists of results for every pairing. + run_unittest(CoercionTest) if __name__ == "__main__": |
