0
我试图重复运行一个参数化的测试。它在执行测试时似乎不遵循顺序。我尝试使用pytest-repeat和pytest.mark.parametrize,但我仍然没有得到期望的结果。 代码是pytest参数重复测试的执行顺序似乎是错误的
conftest.py
scenarios = [('first', {'attribute': 'value'}), ('second', {'attribute': 'value'})]
id = [scenario[0] for scenario in scenarios]
@pytest.fixture(scope="function", params=scenarios, ids=id)
def **get_scenario**(request):
return request.param
test_param.py
@pytest.mark.parametrize("count",range(3))
def test_scenarios(get_scenario,count):
assert get_scenario
当我执行
py.test test_param.py
结果我得到的是
test_scenarios[first-0]
test_scenarios[first-1]
test_scenarios[first-2]
test_scenarios[second-0]
test_scenarios[second-1]
test_scenarios[second-2]
结果IAM 期待是
test_scenarios[first-0]
test_scenarios[second-0]
test_scenarios[first-1]
test_scenarios[second-1]
test_scenarios[first-2]
test_scenarios[second-2]
有没有什么办法可以使它像工作作为测试“第一”设置日期和“第二”会取消数据,因此我需要维护订单,以便我可以运行重复测试。这些测试基本上是用于性能分析的,它测量了通过API设置数据和清除数据的时间。任何帮助非常感谢。在此先感谢