conftest.py 962 Bytes
Newer Older
zzy 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 32 33 34
# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   test62
# FileName:      conftest.py
# Author:       lao_zhao
# Datetime:     2024/9/4 15:43
# Description:
# 
# ---------------------------------------------------------------------------
import pytest
from apiAutoTest_v3.common.db import DB
from apiAutoTest_v3.request_method.request_method import RequestMethod


# DB自定义固件
@pytest.fixture(scope="session")
def fix_db():
    db = DB()
    yield db
    db.close()


# RequestMethod自定义固件
@pytest.fixture(scope="session")
def fix_req():
    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")