numpy.testing.assert_warns()

numpy.testing.assert_warns

numpy.testing.assert_warns(warning_class, *args, **kwargs) [source]

Fail unless the given callable throws the specified warning.

A warning of class warning_class should be thrown by the callable when invoked with arguments args and keyword arguments kwargs. If a different type of warning is thrown, it will not be caught, and the test case will be deemed to have suffered an error.

If called with all arguments other than the warning class omitted, may be used as a context manager:

with assert_warns(SomeWarning):
do_something()

The ability to be used as a context manager is new in NumPy v1.11.0.

New in version 1.4.0.

Parameters:

warning_class : class

The class defining the warning that func is expected to throw.

func : callable

The callable to test.

*args : Arguments

Arguments passed to func.

**kwargs : Kwargs

Keyword arguments passed to func.

Returns:

The value returned by func.

© 2008–2016 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.11.0/reference/generated/numpy.testing.assert_warns.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部