def get_data(): """读yaml文件数据""" lis = [] # data = GetData.get_yml_data("sum.yml") # 静态方法调用 data = GetData().get_yml_data("sum.yml") for i in data.values(): lis.append(tuple(i.values())) return lis
def search_data(): """组装搜索测试数据""" # [("1", "休眠"), ("m", "MAC地址"), ("w", "WPS按钮")] # 存储数据列表 search_value = [] data = GetData().get_yml_data("search.yml") for i in data.values(): search_value.append(tuple(i.values())) return search_value
def login_data(): # 空列表 login_list = [] data = GetData().get_yml_data("login.yml") for i in data.values(): login_list.append((i.get("name"), i.get("pwd"), i.get("toast"), i.get("exp"))) return login_list
def get_yaml(): # 空列表 data_l = [] # 返回yaml文件中的数据 data = GetData().get_yml_data("sum.yml") # 获取data字典的所有value for i in data.values(): # 解析组装数据 data_l.append(tuple(i.values())) return data_l
def get_yaml(): data_l = [] # with open("G:\\Users\Lenovo\PycharmProjects\sh_app13_day10_1\Data\sum.yml","r") as f: # with open(r"./Data/sum.yml", "r") as f: # with open(r"./Data"+os.sep+"sum.yml", "r") as f: data = GetData().get_yml_data("sum.yml") # data=yaml.safe_load(f) # print("data={}".format(data)) for i in data.values(): data_l.append(tuple(i.values())) print(data_l) return data_l
def get_publish_article_data(): data_list = [] data = GetData.get_json_data( 'publish_audit_article.json')['mp_publish_article'] data_list.append( (data['title'], data['content'], data['channel'], data['exp'])) return data_list
def search_data(): # 定义空列表 search_list = [] data = GetData.get_yaml_data("data_search.yml") for i in data.values(): #添加元祖数据到列表 search_list.append((i.get("search_data"), i.get("exp_data"))) return search_list
def sum_data(): # 空列表 存储测试数据 sum_list = [] # 读取yaml文件数据 data = GetData.get_yaml_data("sum.yml") for i in data.values(): # 添加元组数据到列表 sum_list.append((i.get("a"), i.get("b"), i.get("c"))) return sum_list
def sum_data(): # 定义空列表 sum_list = [] data = GetData.get_yaml_data("data_sum.yml") for i in data.values(): #添加元祖数据到列表 sum_list.append((i.get("a"), i.get("b"), i.get("c"))) return sum_list
def sum_data(): # 空列表 存储测试数据 sum_list = [] # 打开文件 data = GetData.get_yaml_data("sum.yml") for i in data.values(): # print("tup:", (i.get("a"), i.get("b"), i.get("c"))) # 添加元组数据到列表 sum_list.append((i.get("a"), i.get("b"), i.get("c"))) return sum_list
def sum_data(): liebiao = [] # with open("./Data/sum.yaml", "r", encoding="utf-8") as f: # # 使用yaml加载数据 # data = yaml.safe_load(f) # 返回字典 data = GetData.get_yaml_data("sum.yaml") # 通过调用封装的打开加载yaml数据的方法 for i in data.values(): # 遍历字典并取所有values值 print("i: ", i) liebiao.append((i.get("a"), i.get("b"), i.get("c"))) print(liebiao) return liebiao
def build_data(tag): """ :param tag: :return: """ data_list_success = [] data_list_fail = [] data = GetData().get_yml_data('login.yml') for key in data: # 'success': case_num, name, pwd, exp_data: case_num = key name = data.get(key).get('username') pwd = data.get(key).get('passwd') toast = data.get(key).get('toast') exp_data = data.get(key).get('exp_data') if tag == 'success' and not toast: # 正向用例 data_list_success.append((case_num, name, pwd, exp_data)) elif tag == 'fail' and toast: data_list_fail.append((case_num, name, pwd, toast, exp_data)) # print("data_list_success: ",data_list_success) # print("data_list_fail: ", data_list_fail) if tag == 'success': # 正向用例 return data_list_success else: return data_list_fail
def get_login_data(): # 空列表存储数据 login_list = [] # 读取json数据 data = GetData.get_json_data("login.json") # 遍历 for i in data: # 添加数据到列表 login_list.append((i.get("desc"), i.get("account"), i.get("password"), i.get("toast"), i.get("exp") )) return login_list
def get_audit_data(): data_list = [] data = GetData.get_json_data( 'publish_audit_article.json')['mis_audit_article'] data_list.append((data['title'], data['exp'])) return data_list
def get_mp_login_data(): data_list = [] data = GetData.get_json_data('publish_audit_article.json')['mp_login'] data_list.append((data['phone'], data['code'], data['exp'])) return data_list
def get_mis_login_data(): data_list = [] data = GetData.get_json_data('publish_audit_article.json')['mis_login'] data_list.append((data['account'], data['password'], data['exp'])) return data_list
def date(): # 成功数据列表 suc_list = [] # 失败数据列表 fail_list = [] # 实例化数据读取文件 value = GetData().get_yml_data("login_data.yml") for i in value.keys(): if value.get(i).get("toast"): fail_list.append((i, value.get(i).get("user"), value.get(i).get("pwd"), value.get(i).get("toast"), value.get(i).get("excep"))) else: suc_list.append((i, value.get(i).get("user"), value.get(i).get("pwd"), value.get(i).get("excep"))) return {"suc": suc_list, "fail": fail_list}
def get_login_data(): # [()] 成功数据列表 suc_list = [] # [(用例编号, 用户名, 密码, 预期结果)] # [()] fail_list = [] # [(用例编号, 用户名, 密码, toast获取消息, 预期结果)] # 读文件数据 data = GetData().get_read_yml("login_data.yml").get("Login_data") for i in data.keys(): if data.get(i).get("toast_mes"): # 预期失败用例添加 fail_list.append( (i, data.get(i).get("username"), data.get(i).get("passwd"), data.get(i).get("toast_mes"), data.get(i).get("exp_data"))) else: # 预期成功用例添加 suc_list.append( (i, data.get(i).get("username"), data.get(i).get("passwd"), data.get(i).get("exp_data"))) return {"suc": suc_list, "fail": fail_list}