官方实例
# content of test_expectation_xfail
import pytest
@pytest.mark.parametrize(
    "test_input, expected",
    [("3+5",8),("2+4",6),pytest.param("6*9",42,marks=pytest.mark.xfail)],
)
def test_eval(test_input, expected):
    assert eval(test_input) == expected
 
解读与实操
可以在参数化标记单独的测试实例,例如使用内置的mark.xfail
先前导致失败的一个参数集现在显示为xfailed(预计会失败)测试

场景应用
测试过程中,对已提Bug的问题单可使用这种方式标记,并最终体现在测试报告中。


















