def get_role_info(cls, path, role_data): # 读表格 book = Utility.read_excell(path) role_sheet = book.sheet_by_name("roles") user_info = {} user_list = [] # 遍历每一行 for i in range(1, role_sheet.nrows): # 读取 角色 判断账号 role_info = role_sheet.cell(i, 1).value.strip() # 找到要找的角色 if role_data in role_info: # 读取账号、密码 url = role_sheet.cell(i, 3).value user_datas = role_sheet.cell(i, 4).value.splitlines() for data in user_datas: # “=”切割 param = data.split("=") user_info[param[0].strip()] = param[1].strip() user_list.append(url) user_list.append(user_info) return user_list else: return None
def get_excell_data(cls, path, sheet_name, type_name, *clos): # 读取表格 book = Utility.read_excell(path) # 得到具体工作表 sheet_target_name = book.sheet_by_name(sheet_name) # 定义 返回的列表 test_case_list_directory = [] # 遍历读取 for i in range(1, sheet_target_name.nrows): type_clos = sheet_target_name.cell(i, 0).value if type_name in type_clos: # 空字典 test_case_list = [] clos_dict = {} # 具体列 url_clos = sheet_target_name.cell(i, clos[0]).value param_clos = sheet_target_name.cell(i, clos[1]).value value_clos_expect = sheet_target_name.cell( i, clos[2]).value.strip() # 添加网址 clos_dict["url"] = url_clos if param_clos != "无参数": value_clos_datas = param_clos.splitlines() step_dict = {} for clos_data in value_clos_datas: # 排除空行 if clos_data: # 切割,用"=" data_split = clos_data.split("=") # = 左边为键,右边为值 step_dict[ data_split[0].strip()] = data_split[1].strip() # 添加参数 clos_dict["step"] = step_dict # 添加预期 clos_dict["expect"] = value_clos_expect # 添加列表 test_case_list.append(clos_dict) test_case_list_directory.append(test_case_list) return test_case_list_directory