【发布时间】:2010-08-27 19:13:48
【问题描述】:
我正在使用nose 编写单元测试,我想检查一个函数是否引发警告(该函数使用warnings.warn)。这是一件很容易做到的事情吗?
【问题讨论】:
-
import warnings; import nose然后with nose.tools.assert_warns(DeprecationWarning): warnings.warn(DeprecationWarning)。
标签: python unit-testing warnings nose