我有一个 pytest 测试,可以针对两个不同的数据库测试几个输入。我两次使用参数化标记来做到这一点:
@pytest.mark.parametrize(
"input_type",
[
pytest.param("input_1"),
pytest.param("input_2"),
],
)
@pytest.mark.parametrize(
"db_type",
[
pytest.param("db_type_1"),
pytest.param("db_type_2"),
],
)
我的经验是仅在input_1
使用db_type_2
(例如)测试由于错误而失败但使用不同的数据库通过运行相同的输入时。我只想将input_1
anddb_type_2
组合标记为 xfail,而所有其他组合不应标记为 xfail。我找不到该怎么做。
如果标记db_type_2
为 xfail:
@pytest.mark.parametrize(
"db_type",
[
pytest.param("db_type_1"),
pytest.param("db_type_2", marks=pytest.mark.xfail)
],
)
所有输入都将失败,这不是我正在寻找的行为。有人可以帮我吗?