1

I have a dictionary:

methodCategory = methodCategory2 (it is dynamic variable, so don't mind it)
methods = {'methodCategory': ['methodname1', 'methodname2'],
           'methodCategory2': ['methodname1', 'methodname2''],
           ...
           }

And I also have a pytest Class:

@pytest.mark.parameterized('methodname', methods[methodCategory])
class TestName:
def test_1(methodname):


def test_2(methodname):


def test_3(methodname):


def test_4(methodname):

I want to do all tests for each methodname first, then do all test for the second methodname:

test_1[methodname1]
test_2[methodname1]
test_3[methodname1]
test_4[methodname1]
test_1[methodname2]

but it goes like:

test_1[methodname1]
test_1[methodname2]
test_2[methodname1]
test_2[methodname2]

How can I loop one methodname through all tests, then loop the 2nd methodname?

  • Your question may already have an answer here: https://stackoverflow.com/questions/31957216/maintaining-order-of-test-execution-when-parametrizing-tests-in-test-class – FloWil Dec 07 '20 at 09:57
  • I can't get it, pytest_generate_tests looks really compicated. I need help. – Klevtsov Andrey Dec 07 '20 at 10:49

0 Answers0