[TIP] How to control combinations of parameterization in pytest?

arun kali raja arunsep886 at gmail.com
Fri May 19 07:04:18 PDT 2017


Hi all,

My test.py file looks something like this:

test.py

pytest_generate_tests(metafunc):
   metafunc.parametrize('moduleFixture',[val1,val2],indirect=True,scope='module')
   metafunc.parametrize('functionFixture',[val1,val2],indirect=True,scope='function')
@pytest.fixture(scope='module')def moduleFixture(request):
   '''
   does something
   '''
@pytest.fixture(scope='function')def functionFixture(request):
   '''
   does something
   '''
def test_1(moduleFixture, functionFixture):
   '''
   does tests...
   '''

If i actually using pytest it generates 4 Testcases

test_1 [val1-val1]
test_1 [val1-val2]
test_1 [val2-val1]
test_1 [val2-val2]

But actually, val1-val2 and val2-val1 are invalid combinations for me!! :(

now how do control the permutation combinations and make sure that my
testcase skips for these wrong combinations?
[
Have posted the same in stackOverflow too..

http://stackoverflow.com/questions/44072081/how-to-control-combinations-of-parameterization-in-pytest

]
-- 
B.Arun Kaliraja
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20170519/99c22bc3/attachment-0001.htm>


More information about the testing-in-python mailing list