import pytest
# 类,手动调用
@pytest.fixture(scope="class", autouse=False) # 类 级别,手动调用
def exec_db_sql():
print("执行SQL...")
yield
print("关闭数据库")
class Test_Run1():
def test1(self):
print("测试1.....")
def test2(self):
print("测试2.....")
def test3(self):
print("测试3.....")
print("--------------------------------")
@pytest.mark.usefixtures("exec_db_sql") # 手动指定,类前后调用exec_db_sql
class Test_Run2():
def test_01(self):
print("测试1.....")
def test_02(self):
print("测试2.....")
def test_03(self):
print("测试3.....")