优化断言 数据类型 增加 接口关联相关

This commit is contained in:
jing song 2021-09-18 18:03:18 +08:00
parent aed3113c11
commit facd86beb6
3 changed files with 8 additions and 5 deletions

View File

@ -94,6 +94,7 @@ def assert_text(hope_res, real_res,third_data=None):
raise
elif h_res["asserttype"] == "!=":
try:
h_res["value"] = replace_random(str(h_res["value"]), res=third_data)
with allure.step("json断言判断不等"):
allure.attach(name="json期望结果", body=str(h_res))
allure.attach(name='json实际实际结果', body=str(r_res))
@ -105,6 +106,7 @@ def assert_text(hope_res, real_res,third_data=None):
elif h_res["asserttype"] == "in":
r_res = str(r_res)
try:
h_res["value"] = replace_random(str(h_res["value"]), res=third_data)
with allure.step("json断言判断包含"):
allure.attach(name="期望结果", body=str(h_res))
allure.attach(name='实际实际结果', body=str(r_res))

View File

@ -298,10 +298,10 @@ from alarm
{'time': '2021-09-11', 'number': 7}, {'time': '2021-09-12', 'number': 4},
{'time': '2021-09-13', 'number': 22}, {'time': '2021-09-14', 'number': 19},
{'time': '2021-09-15', 'number': 38}, {'time': '2021-09-16', 'number': 39}]}
print(replace_random(js, res=res1))
t = "$GetTime(time_type=past,layout=%Y-%m-%d 00:00:00,unit=0,0,0,1,4)$"
# print(replace_random(js, res=res1))
t = "$GetTime(time_type=past,layout=10timestamp,unit=0,0,0,0,0)$"
# print(replace_random(choice_num))
# print(replace_random(t))
print(replace_random(t))
# pattern = re.compile(r'\$json\(' + '$.data.alarm[1].number'.replace('$',"\$").replace('[','\[') + r'\)\$')
# # key = str(sql_json(i))
# key = "123"

View File

@ -7,7 +7,8 @@ datapath = dir_manage("${pro_dir}$") + dir_manage("${test_suite}$")+dir_manage("
def ini_yaml(filename, path=datapath):
with open(path + "/" + filename, 'r', encoding="utf-8") as f:
# encoding="utf-8" 视情况加
with open(path + "/" + filename, 'r') as f:
file_data = f.read()
data = yaml.load(file_data, Loader=yaml.FullLoader)
@ -16,7 +17,7 @@ def ini_yaml(filename, path=datapath):
if __name__ == '__main__':
# get_yaml_data(r"F:\api2.0\config\runConfig.yml")
runConfig_dict = ini_yaml("thirdData.yml")
runConfig_dict = ini_yaml("123.yml")
# case_level = runConfig_dict[0]["address"].format(**{"home_id": "123"})
print(runConfig_dict)
# print(case_level)