summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2013-05-31 20:52:56 +0200
committerSebastian Berg <sebastian@sipsolutions.net>2013-06-09 17:00:46 +0200
commit0e9dccd0b8375a487b435411eb58f00d5d4a8bdc (patch)
treec89d68239d59c392eb6ec6b4091c100cdead989b /numpy
parent187f128563da83b8f202264658dc4dfa80899e93 (diff)
downloadnumpy-0e9dccd0b8375a487b435411eb58f00d5d4a8bdc.tar.gz
MAINT: Use warnings context manager instead of doing it by hand
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/tests/test_deprecations.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
index 3ad264583..e993494ea 100644
--- a/numpy/core/tests/test_deprecations.py
+++ b/numpy/core/tests/test_deprecations.py
@@ -90,18 +90,17 @@ class _DeprecationTestCase(object):
raise AssertionError("%i warnings found but %i expected"
% (len(self.log), num))
- warnings.filterwarnings("error", message=self.message,
- category=DeprecationWarning)
-
- try:
- function(*args, **kwargs)
- if exceptions != tuple():
- raise AssertionError("No error raised during function call")
- except exceptions:
- if exceptions == tuple():
- raise AssertionError("Error raised during function call")
- finally:
- warnings.filters.pop(0)
+ with warnings.catch_warnings():
+ warnings.filterwarnings("error", message=self.message,
+ category=DeprecationWarning)
+
+ try:
+ function(*args, **kwargs)
+ if exceptions != tuple():
+ raise AssertionError("No error raised during function call")
+ except exceptions:
+ if exceptions == tuple():
+ raise AssertionError("Error raised during function call")
def assert_not_deprecated(self, function, args=(), kwargs={}):