首页 > 其他分享 >pytest xfail 已知错误 失败也不报错

pytest xfail 已知错误 失败也不报错

时间:2023-07-21 12:23:35浏览次数:31  
标签:__ sum xfail pytest 报错 main

import pytest
@pytest.mark.parametrize('a,b,sum',[  # 参数化出来3组数据
    (1,2,3),
    (2,3,5),
    (3,-19,-16)
])
def test_add(a,b,sum):
    assert a+b==sum
# 如果 名称等于main 输出pytest.main([文档,sv参数])



@pytest.mark.xfail # 已知的错误失败也不报错
def test_expected_failure():
    assert 1 + 1 == 3

if __name__=='__main__':
    pytest.main([__file__,'-sv'])

 

标签:__,sum,xfail,pytest,报错,main
From: https://www.cnblogs.com/haha1988/p/17570959.html

相关文章