csv 数据驱动 为了解决数据量大 导致yaml文件重复太多
yaml_util.py
import os
import jsonpath
import yaml
from pytestdemo.common.base_util import get_path
from pytestdemo.common.csv_util import analysis_parameters
def read_config_file(one_node,two_node):
with open(f'{get_path()}/common/config.yml',encoding="utf-8") as f:
value=yaml.load(f,yaml.FullLoader)
# print(value[one_node][two_node])
return value[one_node][two_node]
def read_extract_file(node_name):
with open(f'{get_path()}/common/extract.yml',encoding="utf-8") as f:
value=yaml.load(f,yaml.FullLoader)
return value[node_name]
def write_extract_file(data):
with open(f'{get_path()}/common/extract.yml',encoding="utf-8",mode="a") as f:
yaml.dump(data,f,allow_unicode=True)
def clean_extract_file():
with open(f'{get_path()}/common/extract.yml',encoding="utf-8",mode="w"