"""YAML 测试数据读取器(数据驱动的数据面)。""" import os import yaml ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) def read_yaml(filepath): """读取 YAML 文件并返回解析后的 dict。 :param filepath: YAML 文件路径(绝对路径,或相对工程根目录的路径) """ if not os.path.isabs(filepath): filepath = os.path.join(ROOT_DIR, filepath) with open(filepath, encoding="utf-8") as f: return yaml.safe_load(f.read())