0
点赞
收藏
分享

微信扫一扫

pytest -3 前后置 autouse=True

SPEIKE 2023-03-28 阅读 60

import pytest

@pytest.fixture(scope="session", autouse=True)             # 只在类 前/后自动执行, autouse
def exec_db_sql():
    print("执行SQL...")                                     # 前置
    yield                                                   # 后置
    print("关闭数据库")

class Test_Run():
    def test1(self):
        print("测试1.....")
    
    def test2(self):
        print("测试2.....")

    def test3(self):                                 
        print("测试3.....")








举报

相关推荐

0 条评论