在这里输入
class CommonUTil:
def is_contain(self,str_one,str_two):
"""
判断一个字符串是否在另外一个字符串中
:param str_one: 查找的字符串
:param str_two: 被查找的字符串
:return:
"""
flag = None
if isinstance(str_one,str_two):
str_one = str_one.encode('unicode-escape').decode('utf-8')
# return operator(str_one,str_two)
if str_one in str_two:
print(str_one)
print(str_two)
flag = True
else:
print(str_one)
print(str_two)
flag = False
return flag
代码
def go_on_run(self):
res = None
row_count = self.data.get_case_lines()
# print(row_count)
for i in range(1,row_count):
# cookie = None
# get_cookie = None
url = self.data.get_request_url(i)
method = self.data.get_request_method(i)
is_run = self.data.get_is_run(i)
data = self.data.get_data_for_json(i)
header = self.data.is_header(i)
expect_res = self.data.get_expcet_data(i)
# expect = json.loads(expect_res)
# 转换为字典
headers =json.loads(header)
print(expect_res)
print(type(expect_res))
if is_run:
res = self.run_method.run_main(method,url,data,headers)
if self.com_util.is_contain(expect_res,res):
print("测试通过")
else:
print("测试失败")
return res
# return json.loads(res)
# print(res)
# print(type(res1))
if name == ‘main’:
run = RunTest()
print(run.go_on_run())