pytest running scenarios in the correct order in the class
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So I have the following structure: class Test(object): def test_1(self): pass def test_2(self): pass def test_3(self): pass it runs great, NOW I'm adding the "scenarios" (as it's recommended at pytest - A quick port of “testscenarios” ): def pytest_generate_tests(metafunc): idlist = [] argvalues = [] for scenario in metafunc.cls.scenarios: idlist.append(scenario[0]) items = scenario[1].items() argnames = [x[0] for x in items] argvalues.append(([x[1] for x in items])) metafunc.parametrize(argnames, argvalues, ids=idlist) class Test(object):