Python pytest参数化多个测试的执行顺序
我正在使用pytest_generate_tests()尝试pytest参数化: conftest.py 在这种配置中,每个测试都会使用其所有参数运行,并且只有在完成下一个测试并启动其参数后才会运行。我希望以这种方式配置测试,当所有测试都应该循环运行时,我使用第一个参数,然后使用第二个参数,依此类推 例如,a具有以下输出:Python pytest参数化多个测试的执行顺序,python,python-2.7,python-3.x,pytest,Python,Python 2.7,Python 3.x,Pytest,我正在使用pytest_generate_tests()尝试pytest参数化: conftest.py 在这种配置中,每个测试都会使用其所有参数运行,并且只有在完成下一个测试并启动其参数后才会运行。我希望以这种方式配置测试,当所有测试都应该循环运行时,我使用第一个参数,然后使用第二个参数,依此类推 例如,a具有以下输出: test_cliautoconfig.py::test_check_conf_mode[cliautoconfigargs0] test_cliautoconfig.py::
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]
我想要下一个:
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]
对不起,这是一个问题。 找到答案 conftest.py
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]
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]
def pytest_generate_tests(metafunc):
if 'cliautoconfigargs' in metafunc.fixturenames:
metafunc.parametrize(
'cliautoconfigargs', list(<some list of params>), scope="class"
)
class TestCommand:
def test_check_conf_mode(self, cliautoconfigargs):
assert True
def test_enable_disable_command(self, cliautoconfigargs):
assert True