pytest xfail 已知错误 失败也不报错
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'])