[TIP] Parameterizing fixtures

arun kali raja arunsep886 at gmail.com
Fri May 5 05:35:29 PDT 2017


My testcode looks something like below:

def modFixture_1(request):

def modFixture_2(request,

def test_001(testCase,

I am able to parametrize fixture "modFixture_2" using the below statement:

@pytest.mark.parametrize('modFixture_2', ["someValue"],

But i want to parameterize "modFixture_1" fixture. How to go about
this? (i dont want to include that explicitly inside my testcase as i
dont want anyone to use the return value of that fixture inside my

I dont want to go with a static way of parameterization :
@pytest.fixture(params=['a', 'b'])

because some of my testcases may parameterize the fixture and some may not
and the values may also differ for each testcase..

Also is it possible to pass the result of one fixture to another during the
parameterization phase.?

like say the request fixture itself as below:

@pytest.mark.parametrize('modFixture_1', [genValues(request)],

பா. அருண் காளி ராசா
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20170505/cc4bf28c/attachment.html>

More information about the testing-in-python mailing list