In addition to generating the test, you can make this “fixture” for any number of sub-fixtures used dynamically. To do this, determine the actual device that will be used as the parameter:
@pytest.fixture
def arg(request):
return request.getfuncargvalue(request.param)
am ( arg
arg
):
@pytest.mark.parametrize('arg', ['foo', 'bar'], indirect=True)
def test_me(arg):
print(arg)
, :
@pytest.fixture
def foo():
return 'foo'
@pytest.fixture
def bar():
return 'bar'
, :
$ pytest test_me.py -s -v -ra
collected 2 items
test_me.py::test_me[foo] foo
PASSED
test_me.py::test_me[bar] bar
PASSED