import pytest
@pytest.mark.run(order=2)
def test_case01():
print("1执行")
@pytest.mark.run(order=1)
def test_case02():
print("2执行了")终端输入:pytest -vs .py文件 运行
结果:
第七章/main3/test_demo01.py::test_case02 2执行了
PASSED
第七章/main3/test_demo01.py::test_case01 1执行
PASSED