diff options
author | Tim Peters <tim.peters@gmail.com> | 2006-05-30 02:25:25 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2006-05-30 02:25:25 (GMT) |
commit | aba19bc45fb3f0c45cb4511e2b9c1fca637fb2b3 (patch) | |
tree | c4b3be408a83ebc293370b3af1e99d858e026d76 /Lib/test/test_struct.py | |
parent | 6067f20172842775933b4089ebdf9cbcdd4deb7c (diff) | |
download | cpython-aba19bc45fb3f0c45cb4511e2b9c1fca637fb2b3.zip cpython-aba19bc45fb3f0c45cb4511e2b9c1fca637fb2b3.tar.gz cpython-aba19bc45fb3f0c45cb4511e2b9c1fca637fb2b3.tar.bz2 |
deprecated_err(): Stop bizarre warning messages when the tests
are run in the order:
test_genexps (or any other doctest-based test)
test_struct
test_doctest
The `warnings` module needs an advertised way to save/restore
its internal filter list.
Diffstat (limited to 'Lib/test/test_struct.py')
-rw-r--r-- | Lib/test/test_struct.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index 701f7fd..9f43c09 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -50,8 +50,12 @@ def any_err(func, *args): func.__name__, args) def deprecated_err(func, *args): + # The `warnings` module doesn't have an advertised way to restore + # its filter list. Cheat. + save_warnings_filters = warnings.filters[:] warnings.filterwarnings("error", r"""^struct.*""", DeprecationWarning) - warnings.filterwarnings("error", r""".*format requires.*""", DeprecationWarning) + warnings.filterwarnings("error", r""".*format requires.*""", + DeprecationWarning) try: try: func(*args) @@ -65,7 +69,7 @@ def deprecated_err(func, *args): raise TestFailed, "%s%s did not raise error" % ( func.__name__, args) finally: - warnings.resetwarnings() + warnings.filters[:] = save_warnings_filters[:] simple_err(struct.calcsize, 'Z') |