pytest(1) - 执行顺序
import pytest
def setup_module():
print("整个模块开始只执行一次")
def teardown_module():
print("整个模块结束只执行一次")
def setup_function():
print("不在类中的方法先执行")
def teardown_function():
print("不在类中的方法先执行")
def test_out():
print("不在类中")
class TestOne:
def setup_class(self):
print("类前执行")
def teardown_class(self):
print("类后执行")
def setup_method(self):
print("方法前执行")
def teardown_method(self):
print("方法后执行")
@pytest.mark.parametrize("a,b", [(1, 2), (2, 3), (3, 4)],
ids=["1", "2", "3"])
def test_one(self, a, b):
print(a + b)