# -*-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()

def pytest_collection_modifyitems(items):
    # item表示每个测试用例，解决用例名称中文显示问题
    for item in items:
        item.name = item.name.encode("utf-8").decode("unicode-escape")
        item._nodeid = item._nodeid.encode("utf-8").decode("unicode-escape")