小编Raj*_*waj的帖子

我们可以有条件地调用 pytest 夹具吗?

我的用例是仅在满足特定条件时调用固定装置。但由于我们需要调用 pytest 夹具作为测试函数的参数,因此每次运行测试时都会调用它。

我想做这样的事情:

@pytest.parameterize("a", [1, 2, 3])
def test_method(a):
    if a == 2:
       method_fixture
Run Code Online (Sandbox Code Playgroud)

python fixtures pytest

4
推荐指数
1
解决办法
4812
查看次数

标签 统计

fixtures ×1

pytest ×1

python ×1