Is it possible to get the parameter ID
in a Pytest fixture?
import pytest
@pytest.fixture(
params = ['a', 'b', 'c'],
ids = ['x', 'y', 'z'])
def foo(request):
myParam = request.param
myID = "How do I get the current ID?"
One way to do it is passing the ID along as a parameter:
import pytest
params = ['a', 'b', 'c']
ids = ['x', 'y', 'z']
@pytest.fixture(params=zip(params,ids), id=lambda x: x[1]):
def foo(request):
myParam = request.param[0]
myID = request.param[1]
This is ugly, but it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With