0
点赞
收藏
分享

微信扫一扫

Pytest -5 类手动调用

读思意行 2023-03-28 阅读 66

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.....")





举报

相关推荐

0 条评论