summaryrefslogtreecommitdiff
path: root/numpy/testing/nosetester.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/testing/nosetester.py')
-rw-r--r--numpy/testing/nosetester.py41
1 files changed, 18 insertions, 23 deletions
diff --git a/numpy/testing/nosetester.py b/numpy/testing/nosetester.py
index f1ebd2265..f11f04b20 100644
--- a/numpy/testing/nosetester.py
+++ b/numpy/testing/nosetester.py
@@ -363,32 +363,27 @@ class NoseTester(object):
if raise_warnings in _warn_opts.keys():
raise_warnings = _warn_opts[raise_warnings]
- # Preserve the state of the warning filters
- warn_ctx = numpy.testing.utils.WarningManager()
- warn_ctx.__enter__()
- # Reset the warning filters to the default state,
- # so that running the tests is more repeatable.
- warnings.resetwarnings()
- # If deprecation warnings are not set to 'error' below,
- # at least set them to 'warn'.
- warnings.filterwarnings('always', category=DeprecationWarning)
- # Force the requested warnings to raise
- for warningtype in raise_warnings:
- warnings.filterwarnings('error', category=warningtype)
- # Filter out annoying import messages.
- warnings.filterwarnings('ignore', message='Not importing directory')
- warnings.filterwarnings("ignore", message="numpy.dtype size changed")
- warnings.filterwarnings("ignore", message="numpy.ufunc size changed")
- warnings.filterwarnings("ignore", category=ModuleDeprecationWarning)
-
- try:
+ with warnings.catch_warnings():
+ # Reset the warning filters to the default state,
+ # so that running the tests is more repeatable.
+ warnings.resetwarnings()
+ # If deprecation warnings are not set to 'error' below,
+ # at least set them to 'warn'.
+ warnings.filterwarnings('always', category=DeprecationWarning)
+ # Force the requested warnings to raise
+ for warningtype in raise_warnings:
+ warnings.filterwarnings('error', category=warningtype)
+ # Filter out annoying import messages.
+ warnings.filterwarnings('ignore', message='Not importing directory')
+ warnings.filterwarnings("ignore", message="numpy.dtype size changed")
+ warnings.filterwarnings("ignore", message="numpy.ufunc size changed")
+ warnings.filterwarnings("ignore", category=ModuleDeprecationWarning)
+
from .noseclasses import NumpyTestProgram
- argv, plugins = self.prepare_test_args(label,
- verbose, extra_argv, doctests, coverage)
+ argv, plugins = self.prepare_test_args(
+ label, verbose, extra_argv, doctests, coverage)
t = NumpyTestProgram(argv=argv, exit=False, plugins=plugins)
- finally:
- warn_ctx.__exit__()
return t.result