summaryrefslogtreecommitdiff
path: root/numpy/testing/tests
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/testing/tests')
-rw-r--r--numpy/testing/tests/test_decorators.py14
-rw-r--r--numpy/testing/tests/test_utils.py12
2 files changed, 14 insertions, 12 deletions
diff --git a/numpy/testing/tests/test_decorators.py b/numpy/testing/tests/test_decorators.py
index 7dbb5a828..721c0ef7e 100644
--- a/numpy/testing/tests/test_decorators.py
+++ b/numpy/testing/tests/test_decorators.py
@@ -1,8 +1,10 @@
from __future__ import division, absolute_import, print_function
+import warnings
+
from numpy.testing import (dec, assert_, assert_raises, run_module_suite,
SkipTest, KnownFailureException)
-import nose
+
def test_slow():
@dec.slow
@@ -172,10 +174,12 @@ def test_deprecated():
assert_raises(AssertionError, non_deprecated_func)
# should be silent
deprecated_func()
- # fails if deprecated decorator just disables test. See #1453.
- assert_raises(ValueError, deprecated_func2)
- # first warnings is not a DeprecationWarning
- assert_raises(AssertionError, deprecated_func3)
+ with warnings.catch_warnings(record=True):
+ warnings.simplefilter("always") # do not propagate unrelated warnings
+ # fails if deprecated decorator just disables test. See #1453.
+ assert_raises(ValueError, deprecated_func2)
+ # warning is not a DeprecationWarning
+ assert_raises(AssertionError, deprecated_func3)
if __name__ == '__main__':
diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py
index c0f609883..c191aea5b 100644
--- a/numpy/testing/tests/test_utils.py
+++ b/numpy/testing/tests/test_utils.py
@@ -503,23 +503,21 @@ class TestWarns(unittest.TestCase):
warnings.warn("yo", DeprecationWarning)
failed = False
- filters = sys.modules['warnings'].filters[:]
- try:
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", DeprecationWarning)
try:
- # Should raise an AssertionError
+ # Should raise a DeprecationWarning
assert_warns(UserWarning, f)
failed = True
- except AssertionError:
+ except DeprecationWarning:
pass
- finally:
- sys.modules['warnings'].filters = filters
if failed:
raise AssertionError("wrong warning caught by assert_warn")
class TestAssertAllclose(unittest.TestCase):
-
+
def test_simple(self):
x = 1e-3
y = 1e-9