# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   Selenium_Project
# FileName:      config.py
# Author:       xxxxxxx
# Datetime:     2024/5/20 20:17
# Description:
# 命名规范：文件名全小写+下划线，类名大驼峰，方法和变量小写+下划线连接，
# 常量大写，变量和常量用名词，方法用动词
# ---------------------------------------------------------------------------
import pytest

from api_test_0520 import log_decorator
from api_test_0520.common.db import DB
from api_test_0520.requests_method.request_method import RequestMethod


@log_decorator
@pytest.fixture(scope="session")
def db_fix():
    db = DB()
    yield db
    db.close()

@log_decorator
@pytest.fixture(scope="session")
def req_fix():
    req = RequestMethod()
    yield req


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