collect_yaml.yaml
case_common:
allureEpic: 开发平台接口
allureFeature: 收藏模块
allureStory: 删除收藏网站接口
def read_cases_by_path_name(yaml_name, file_path=None):
"""
读取测试用例
:param file_path: 文件路径
:param yaml_name: 文件名
:return: 返回获取结果
"""
INFO.logger.info("加载{}/{}文件...........".format(file_path, yaml_name))
full_path = os.path.join(file_path or os.getcwd(), yaml_name)
with open(full_path, mode='r', encoding='utf-8') as f:
value = yaml.safe_load(f)
INFO.logger.info("读取到的数据===》{}".format(value))
return value
@user1ize('case_info', read_cases_by_path_name('collect_yaml.yaml'))
def test_yaml_file(self, case_info):
print(f'case_info内容{case_info}')
为什么运行 test_yaml_file 时,打印的结果是 case_common,而不是 case_common:
allureEpic: 开发平台接口
allureFeature: 收藏模块
allureStory: 删除收藏网站接口。 read_cases_by_path_name('collect_yaml.yaml')) 这里调用的时候,read_cases_by_path_name 打印的结果是 case_common:
allureEpic: 开发平台接口
allureFeature: 收藏模块
allureStory: 删除收藏网站接口。