如何将pytest.lazy_fixture与ids一起使用?

时间:2017-12-11 20:45:15

标签: python automated-tests pytest fixtures

我正在尝试使用lazy_fixture使用类似以下代码的参数来设置灯具:

@pytest.fixture(params=[list_of_something], 
ids=[list_of_ids_for_the_previous_list]
)
def some_fixture(request):
    return request.param

@pytest.mark.parametrize('arg', [
    pytest.lazy_fixture('some_fixture'),
])
def test_func(arg):
    assert arg == 42

现在,当我使用pytest运行时,所有参数都具有相同的ids test_func[arg0]但如果我直接在test_func中使用了夹具some,就像

一样
def test_func(some_fixture):
    assert some_fixture == 42

然后我可以在使用灯具的每个参数时看到所有ids

我的问题是:如何在ids中使用lazy_fixturemark.parametrize

0 个答案:

没有答案