[TIP] Parameterizing fixtures

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


Hi,

My testcode looks something like below:

@pytest.fixture(scope='module')
def modFixture_1(request):
    ...

@pytest.fixture(scope='module')
def modFixture_2(request,
                 modFixture_1):
    ...


def test_001(testCase,
             modFixture_2):
    ...
    ...
    ...


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

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

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
testcase...)

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)],
indirect=['modFixture_1'])




அன்புடன்,
பா. அருண் காளி ராசா
-------------- 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