Esempio n. 1
0
    def get_case_values_of_sheet(self, sheet, case_no):
        """ 从表格里获取case对应的测试数据,返回一个字典 """
        with allure.step("从工作表{0}取得case{1}测试数据,返回为字典".format(sheet, case_no)):
            max_row_num = self.get_row_num(sheet)
            # print(max_row_num)
            excel_key_value = {}
            for row in range(2, max_row_num+1):
                data_key = sheet.cell(row, 2).value
                data_value = sheet.cell(row, 2 + case_no).value
                if data_value is None or data_value == '':
                    data_value = ''
                excel_key_value[data_key] = data_value
        variables_mapping = {}
        # imported_module = importlib.import_module("common.functions.built_in_functions")
        imported_module = importlib.import_module("common.functions.built_in_functions")
        functions_mapping = load_module_functions(imported_module)

        imported_module1 = importlib.import_module("common.functions.mdes_buile_in_functions")
        aaa = load_module_functions(imported_module1)
        functions_mapping.update(aaa)
        while True:
            excel_key_value = parse_data(excel_key_value, variables_mapping=variables_mapping,
                                         functions_mapping=functions_mapping,
                                         raise_if_variable_not_found=False)
            count = 0
            for k, v in excel_key_value.items():
                ev = extract_variables(v)
                ef = extract_functions(v)
                if ev != [] or ef != []:
                    count += 1
            if count == 0:
                break
        return excel_key_value
Esempio n. 2
0
def hand_functions_map():
    module_list = get_functions_modules()
    functions_mapping = {}
    for name in module_list:
        imported_module = importlib.import_module(name)
        custom_functions_map = load_module_functions(imported_module)
        functions_mapping.update(custom_functions_map)
    return functions_mapping
Esempio n. 3
0
 def set_func(self):
     func_list = Script.list(self.project_id)
     module_dict = {}
     if func_list:
         for func in func_list:
             import_module = __import__(
                 f"openapi.script.{self.project_id}.{func.get('script_file')[:-3]}",
                 fromlist=True)
             tmp_dict = load_module_functions(import_module)
             module_dict.update(tmp_dict)
     self.suit_json['project_mapping']['functions'] = module_dict
Esempio n. 4
0
def load_debugtalk_functions():
    """ load project debugtalk.py module functions
        debugtalk.py should be located in project working directory.

    Returns:
        dict: debugtalk module functions mapping
            {
                "func1_name": func1,
                "func2_name": func2
            }

    """
    # load debugtalk.py module
    imported_module = importlib.import_module("debugtalk")
    return load_module_functions(imported_module)
Esempio n. 5
0
def load_debugtalk_functions(path):
    """ load project debugtalk.py module functions
        debugtalk.py should be located in project working directory.

    Returns:
        dict: debugtalk module functions mapping
            {
                "func1_name": func1,
                "func2_name": func2
            }

    """
    # load debugtalk.py module
    path_start1 = os.path.split(path)[-1]
    path_start = os.path.split(os.path.split(path)[0])[-1]
    import_module_name = "{0}.{1}.debugtalk".format(path_start, path_start1)
    imported_module = importlib.import_module(import_module_name)
    # imported_module = importlib.import_module("debugtalk")
    print("---------------> mport-module: {}".format(imported_module))
    return load_module_functions(imported_module)