numpy.testing.dec.deprecated

Here are the examples of the python api numpy.testing.dec.deprecated taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

Example 1

Project: AWS-Lambda-ML-Microservice-Skeleton Source File: test_decorators.py
Function: test_deprecated
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)