在pytest报告中列出python警告的pytest插件
pytest-warnings的Python项目详细描述
pytest警告
在py test报告中列出python警告的py.test插件。
集成在Pytest中>;=3.1.0。
使用量
安装方式:
pip install pytest-warnings
如果您随后键入:
py.test -rw
代码中的任何警告都会在pytest报告中报告。 您可以使用-W选项或--pythonwarnings来执行python可执行文件。
以下示例忽略所有警告,但每次出现时都会打印一次deprecationwarnings:
py.test -rw -W ignore -W once::DeprecationWarning
您还可以将警告转换为实际错误:
py.test -W error
提前使用
通过使用 filterwarnings配置选项。
filterwarnings的工作方式与python的-W标志类似,只是它不会 转义特殊字符。
示例
# pytest.ini [pytest] filterwarnings= default ignore:.*is deprecated.*:Warning error::DeprecationWarning:importlib.*
更改
0.3.0-2017年5月21日
- 添加Travis CI配置。 [dwayne bailey(dwayne bailey)]
- 使轮子通用。 [阿拉吉拉尔(詹姆斯·托克内尔)]
- 由于这个插件集成在Pytest3.1.0中,我们显示了一个不推荐 卸载插件的警告和建议。 [尼科德默斯(布鲁诺·奥利维拉),弗斯丘尔泽]
0.2.0-2016年10月24日
- 添加filterwarnings选项。 [卡罗(马蒂亚斯·布森尼尔)]
0.1.0-2016年6月27日
- 初次发布。 [弗斯丘尔泽(弗洛里安·舒尔泽)]