Reputation: 61
I'm trying pytest parametrization with pytest_generate_tests():
conftest.py
def pytest_generate_tests(metafunc):
if 'cliautoconfigargs' in metafunc.fixturenames:
metafunc.parametrize(
'cliautoconfigargs', list(<some list of params>))
)
test_cliautoconfig.py
def test_check_conf_mode(cliautoconfigargs):
assert True
def test_enable_disable_command(cliautoconfigargs):
assert True
In such configuration each test running with all its parameters and only after it completed the next test with its parameters starting. I'd like to configure testing in such way, when all tests should be cyclicaly run with their first parameter, then with second parameter, and so on.
For example a have the following output:
test_cliautoconfig.py::test_check_conf_mode[cliautoconfigargs0]
test_cliautoconfig.py::test_check_conf_mode[cliautoconfigargs1]
test_cliautoconfig.py::test_enable_disable_command[cliautoconfigargs0]
test_cliautoconfig.py::test_enable_disable_command[cliautoconfigargs1]
I want to have the next one:
test_cliautoconfig.py::test_check_conf_mode[cliautoconfigargs0]
test_cliautoconfig.py::test_enable_disable_command[cliautoconfigargs0]
test_cliautoconfig.py::test_check_conf_mode[cliautoconfigargs1]
test_cliautoconfig.py::test_enable_disable_command[cliautoconfigargs1]
Upvotes: 4
Views: 3641
Reputation: 61
Sory for issue dublication. Found answer in maintaining order of test execution when parametrizing tests in test class
conftest.py
def pytest_generate_tests(metafunc):
if 'cliautoconfigargs' in metafunc.fixturenames:
metafunc.parametrize(
'cliautoconfigargs', list(<some list of params>), scope="class"
)
test_cliautoconfig.py
class TestCommand:
def test_check_conf_mode(self, cliautoconfigargs):
assert True
def test_enable_disable_command(self, cliautoconfigargs):
assert True
Upvotes: 2