This commit is contained in:
Albert 2024-02-27 09:26:13 +08:00
parent e4e945d787
commit 421cb33c13
4 changed files with 19 additions and 19 deletions

View File

@ -17,7 +17,7 @@ def read_config_yaml(one_node, two_node):
:param two_node:第二个节点
:return:返回节点数据
"""
with open(get_object_path() + '/config/config.yaml', encoding='utf-8') as f:
with open(get_object_path() + r'\config\config.yaml', encoding='utf-8') as f:
value = yaml.load(stream=f, Loader=yaml.FullLoader)
return value[one_node][two_node]
@ -28,7 +28,7 @@ def read_config(node):
:param node:节点
:return:返回节点数据
"""
with open(get_object_path() + '/config/config.yaml', encoding='utf-8') as f:
with open(get_object_path() + r'\config\config.yaml', encoding='utf-8') as f:
value = yaml.load(stream=f, Loader=yaml.FullLoader)
return value[node]
@ -39,7 +39,7 @@ def read_extract_yaml(node_name):
:param node_name:节点名称
:return:返回节点数据
"""
with open(get_object_path() + '/config/extract.yaml', encoding='utf-8') as f:
with open(get_object_path() + r'\config\extract.yaml', encoding='utf-8') as f:
value = yaml.load(stream=f, Loader=yaml.FullLoader)
if node_name is None:
return value
@ -53,7 +53,7 @@ def write_extract_yaml(data):
:param data:
:return:返回节点数据
"""
with open(get_object_path() + '/config/extract.yaml', encoding='utf-8', mode='a') as f:
with open(get_object_path() + r'\config\extract.yaml', encoding='utf-8', mode='a') as f:
# 允许写入unicode编码
yaml.dump(data=data, stream=f, allow_unicode=True)
@ -63,5 +63,5 @@ def clear_extract_yaml():
清空extract.yaml文件每次取值之前要做初始化清空操作
:return:返回节点数据
"""
with open(get_object_path() + '/config/extract.yaml', encoding='utf-8', mode='w') as f:
with open(get_object_path() + r'\config\extract.yaml', encoding='utf-8', mode='w') as f:
f.truncate()

View File

@ -1 +1 @@
{"uid":"4b4757e66a1912dae1a509f688f20b0f","children":[],"name":"categories"}
{"uid":"4b4757e66a1912dae1a509f688f20b0f","name":"categories","children":[]}

Binary file not shown.

26
run.py
View File

@ -16,30 +16,30 @@ if __name__ == '__main__':
# 使用allure报告
if REPORT_TYPE == 'allure':
# 复制environment.xml环境设置到allure报告
shutil.copy('environment.xml', 'reports/temps')
shutil.copy('environment.xml', r'reports\temps')
# 等待2s
time.sleep(2)
# 将reports/temps文件夹下临时生成的json格式的测试报告-o输出到reports/allures目录下生成index.html报告
os.system("allure generate reports/temps -o reports/allures --clean")
# 复制allure报告打开.bat文件到reports/allures下
shutil.copy('reports/allure报告打开.bat', 'reports/allures')
# 将reports\temps文件夹下临时生成的json格式的测试报告-o输出到reports\allures目录下生成index.html报告
os.system(r"allure generate reports\temps -o reports\allures --clean")
# 复制allure报告打开.bat文件到reports\allures下
shutil.copy(r'reports\allure报告打开.bat', r'reports\allures')
# 自定义allure报告网页标题
set_windows_title("自动化测试报告标题")
# 自定义allure报告标题
report_title = get_json_data("自动化测试报告")
write_json_data(report_title)
# 调用方法把reports/allures打包成zip文件到reports/report.zip
# zip_reports("./reports/allures", "./reports/report.zip")
# 报告的压缩包reports/report.zip
# allurereport_path = os.path.join("./reports/", "report.zip")
# 调用方法发送报告的压缩包reports/report.zip测试报告到QQ邮箱
# send_mail(allurereport_path)
# 调用方法把reports\allures打包成zip文件到reports\report.zip
zip_reports(r"reports\allures", r"reports\report.zip")
# 报告的压缩包reports\report.zip
allurereport_path = os.path.join(r"reports", "report.zip")
# 调用方法发送报告的压缩包reports\report.zip测试报告到QQ邮箱
send_mail(allurereport_path)
info_log("接口自动化测试完成!")
# 启动allure服务自动打开报告
# os.system('allure serve ./reports/temps')
os.system(r'allure serve reports\temps')
# 使用pytest-tmreport的html报告
elif REPORT_TYPE == 'html':
htmlreport_path = get_object_path() + "reports/report.html"
htmlreport_path = get_object_path() + r"reports\report.html"
webbrowser.open_new_tab(htmlreport_path)
info_log("接口自动化测试完成!")
# 发送测试报告到邮箱