pytest 参数化一般都是对每个函数进行参数化。
即使在测试类上参数化 也是这个测试类下所有函数 分别执行。

@user1ize("times", data)
class Test(object):

    def test_001(self, times):
        print(times)

    def test_002(self, times):
        print(1123123)

    def test_003(self, times):
        print(333333333)

结果的执行顺序:
test_test.py::Test::test_001[1]
test_test.py::Test::test_001[2]
test_test.py::Test::test_001[3]
test_test.py::Test::test_001[5]
test_test.py::Test::test_002[1]
test_test.py::Test::test_002[2]
test_test.py::Test::test_002[3]
test_test.py::Test::test_002[5]
test_test.py::Test::test_003[1]
test_test.py::Test::test_003[2]
test_test.py::Test::test_003[3]
test_test.py::Test::test_003[5]

有没有什么办法让类里的函数按这个顺序执行
test_test.py::Test::test_001[1]
test_test.py::Test::test_002[1]
test_test.py::Test::test_003[1]
test_test.py::Test::test_001[2]
test_test.py::Test::test_002[2]
test_test.py::Test::test_003[2]
test_test.py::Test::test_001[3]
test_test.py::Test::test_002[3]
test_test.py::Test::test_003[3]
test_test.py::Test::test_001[5]
test_test.py::Test::test_002[5]
test_test.py::Test::test_003[5]


↙↙↙阅读原文可查看相关链接,并与作者交流