将非断言失败视为测试错误的pytest插件。

pytest-finer-verdicts的Python项目详细描述


pytest精细判决

将非断言失败视为测试错误的pytest插件。

获取插件

插件可以通过pip install pytest-finer-verdicts安装。 同样,也可以通过 pip uninstall pytest-finer-verdicts

使用量

请考虑文件test.py中的以下片段(可用 temp/test.py在存储库中)。

import pytest


def test_pass():
    assert 70 <= 75


def test_fail():
    assert 75 <= 70


def test_error():
    raise RuntimeError()


def test_pytest_fail():
    pytest.fail("Fail")


def test_pytest_raises():
    with pytest.raises(ValueError):
        raise IndexError()

不带pytest finer verdicts插件,py.test test.py -v将 产生以下输出。

collected 5 items

test.py::test_pass PASSED
test.py::test_fail FAILED
test.py::test_error ERROR
test.py::test_pytest_fail FAILED
test.py::test_pytest_raises ERROR

================================== ERRORS ===================================
_______________________ ERROR at setup of test_error ________________________

    def test_error():
>       raise RuntimeError()
E       RuntimeError

test.py:13: RuntimeError
___________________ ERROR at setup of test_pytest_raises ____________________

    def test_pytest_raises():
        with pytest.raises(ValueError):
>           raise IndexError()
E           IndexError

test.py:22: IndexError
================================= FAILURES ==================================
_________________________________ test_fail _________________________________

    def test_fail():
>       assert 75 <= 70
E       assert 75 <= 70

test.py:9: AssertionError
_____________________________ test_pytest_fail ______________________________

    def test_pytest_fail():
>       pytest.fail("Fail")
E       Failed: Fail

test.py:17: Failed
================ 2 failed, 1 passed, 2 error in 0.05 seconds ================

注意test_errortest_pytest_raises如何标记为 插件测试错误

归因

版权所有(c)2016,Venkatesh Prasad Ranganath

根据BSD 3条款“新”或“修订”许可证(https://choosealicense.com/licenses/bsd-3-clause/

作者:venkatesh prasad ranganath

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在饼图的图例中只包含每个类别的长描述?   json Grails应用程序,可以从Java DAO服务访问数据库如何访问控制器中的服务?   java将大型远程数据库表同步到本地数据库表,该表包含字段“lastModificationTime”   java如何在JFrame中创建交互式地图   web服务如何创建异步Java Restlet web服务?   java开始读取特定字节   java在jTable中返回不带SQL的搜索结果(带DAOMock)   jakarta ee java ee MVC模式,模型和视图是否直接相互通信   当由负载平衡器处理时,java Spring引导CSRF失败   java为什么JavaMail连接超时太长   java IzPack需要从安装程序安装JDK/JRE版本   java如何创建一个只接受实现Iterable的元素的方法   java spring数据存储库无法使用idClass保存实体   java如何从列表中删除重复项?   java在SocketChannel中发送大量数据时,影响速度的因素有哪些?   算法分支和绑定错误:节点1无法转换为java。可比的   java使用邮件API从Swing应用程序创建Jar文件   java枚举与简单常量声明?