diff options
| author | Ezio Melotti <ezio.melotti@gmail.com> | 2010-08-02 22:01:34 (GMT) |
|---|---|---|
| committer | Ezio Melotti <ezio.melotti@gmail.com> | 2010-08-02 22:01:34 (GMT) |
| commit | cc436eb6e83f231c4d5c1bfdd8565b6b4b45effa (patch) | |
| tree | 721bef963ca1ae75eda720540259e65f985b3abf /Lib/test/test_support.py | |
| parent | c355eaa9a97c89e94fd978cf4d8e0f1e668b4851 (diff) | |
| download | cpython-cc436eb6e83f231c4d5c1bfdd8565b6b4b45effa.zip cpython-cc436eb6e83f231c4d5c1bfdd8565b6b4b45effa.tar.gz cpython-cc436eb6e83f231c4d5c1bfdd8565b6b4b45effa.tar.bz2 | |
Merged revisions 78769,79049 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78769 | florent.xicluna | 2010-03-07 21:14:12 +0200 (Sun, 07 Mar 2010) | 2 lines
Refresh the documentation for the test.test_support module.
........
r79049 | florent.xicluna | 2010-03-18 21:51:47 +0200 (Thu, 18 Mar 2010) | 2 lines
#8155: Preserve backward compatibility for test_support.check_warnings(). Add regression tests.
........
Diffstat (limited to 'Lib/test/test_support.py')
| -rw-r--r-- | Lib/test/test_support.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index 69b4d90..2212fce 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -457,11 +457,11 @@ def _filterwarnings(filters, quiet=False): if not seen and not quiet: # This filter caught nothing missing.append((msg, cat.__name__)) - for exc in reraise: - raise AssertionError("unhandled warning %r" % exc) - for filter in missing: - raise AssertionError("filter (%r, %s) did not caught any warning" % - filter) + if reraise: + raise AssertionError("unhandled warning %r" % reraise[0]) + if missing: + raise AssertionError("filter (%r, %s) did not catch any warning" % + missing[0]) @contextlib.contextmanager @@ -473,14 +473,19 @@ def check_warnings(*filters, **kwargs): Optional argument: - if 'quiet' is True, it does not fail if a filter catches nothing - (default False) + (default True without argument, + default False if some filters are defined) Without argument, it defaults to: - check_warnings(("", Warning), quiet=False) + check_warnings(("", Warning), quiet=True) """ + quiet = kwargs.get('quiet') if not filters: filters = (("", Warning),) - return _filterwarnings(filters, kwargs.get('quiet')) + # Preserve backward compatibility + if quiet is None: + quiet = True + return _filterwarnings(filters, quiet) @contextlib.contextmanager |
