diff options
| author | Ralf Gommers <ralf.gommers@googlemail.com> | 2011-03-29 23:15:22 +0200 |
|---|---|---|
| committer | Ralf Gommers <ralf.gommers@googlemail.com> | 2011-03-29 23:15:22 +0200 |
| commit | a3889707c684bc3d4f885927c7d4692147be7e86 (patch) | |
| tree | b3049d70c04fee628c686e91fdb6f9373750731f /numpy/testing/tests | |
| parent | dce8638a727ea42ec97a407209ba0a722bf76380 (diff) | |
| download | numpy-a3889707c684bc3d4f885927c7d4692147be7e86.tar.gz | |
TST: tests for deprecated decorator.
Diffstat (limited to 'numpy/testing/tests')
| -rw-r--r-- | numpy/testing/tests/test_decorators.py | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/numpy/testing/tests/test_decorators.py b/numpy/testing/tests/test_decorators.py index 504971e61..a28e24ac3 100644 --- a/numpy/testing/tests/test_decorators.py +++ b/numpy/testing/tests/test_decorators.py @@ -8,7 +8,7 @@ def test_slow(): def slow_func(x,y,z): pass - assert(slow_func.slow) + assert_(slow_func.slow) def test_setastest(): @dec.setastest() @@ -23,11 +23,11 @@ def test_setastest(): def f_isnottest(a): pass - assert(f_default.__test__) - assert(f_istest.__test__) - assert(not f_isnottest.__test__) + assert_(f_default.__test__) + assert_(f_istest.__test__) + assert_(not f_isnottest.__test__) -class DidntSkipException(Exception): +class DidntSkipException(Exception): pass def test_skip_functions_hardcoded(): @@ -148,9 +148,36 @@ def test_skip_generators_callable(): pass -if __name__ == '__main__': - run_module_suite() +def test_deprecated(): + @dec.deprecated(True) + def non_deprecated_func(): + pass + + @dec.deprecated() + def deprecated_func(): + import warnings + warnings.warn("TEST: deprecated func", DeprecationWarning) + @dec.deprecated() + def deprecated_func2(): + import warnings + warnings.warn("AHHHH") + raise ValueError + @dec.deprecated() + def deprecated_func3(): + import warnings + warnings.warn("AHHHH") + # marked as deprecated, but does not raise DeprecationWarning + 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) + +if __name__ == '__main__': + run_module_suite() |
