""" 测试数据共享文件 """ import pytest import json import os @pytest.fixture def data_read(request) -> dict: """ 读取测试使用的数据 :param request: 接收传递的参数 :return: 字典 """ # 获取当前项目根路径 root_path = os.getcwd() # 获取到要获取数据的键 key = request.param # 读取数据 with open(root_path + r"\data\test_data.json", "r", encoding="utf-8") as f: values = json.load(f) return values[key]