conftest.py 1.05 KB
Newer Older
li-yuanqiao committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   test60
# FileName:      conftest.py
# Author:       lao_zhao
# Datetime:     2024/5/20 16:10
# Description:
# 
# ---------------------------------------------------------------------------
import pytest
from InterfaceAutoTest import log_decorator
from InterfaceAutoTest.common.db import DB
from InterfaceAutoTest.requests_method.requsts_method import RequestsMethod


@log_decorator
@pytest.fixture(scope="session")
def req_fix():
    """创建RequestsMethod对象,并返回"""
    req = RequestsMethod()
    yield req


@log_decorator
@pytest.fixture(scope="session")
def db_fix():
    """创建DB对象,并返回"""
    db = DB()
    yield db
    db.close()

li-yuanqiao committed
32
'''
li-yuanqiao committed
33 34 35 36
def pytest_collection_modifyitems(items):
    # item表示每个测试用例,解决用例名称中文显示问题
    for item in items:
        item.name = item.name.encode("utf-8").decode("unicode-escape")
li-yuanqiao committed
37 38
        item._nodeid = item._nodeid.encode("utf-8").decode("unicode-escape")
'''