阳洁
2023-07-18 99381503fbb2c4e92b0f417b16d9472fee784177
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""
    测试数据共享文件
"""
 
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]