def extract_response(self, extractors): """ extract value from requests.Response and store in OrderedDict. @param (list) extractors [ {"resp_status_code": "status_code"}, {"resp_headers_content_type": "headers.content-type"}, {"resp_content": "content"}, {"resp_content_person_first_name": "content.person.name.first_name"} ] @return (OrderDict) variable binds ordered dict """ if not extractors: return {} logger.log_info("start to extract from response object.") extracted_variables_mapping = OrderedDict() extract_binds_order_dict = utils.convert_to_order_dict(extractors) for key, field in extract_binds_order_dict.items(): extracted_variables_mapping[key] = self.extract_field(field) return extracted_variables_mapping
def init_context(self, level='testcase'): """ testset level context initializes when a file is loaded, testcase level context initializes when each testcase starts. """ if level == "testcase": self.testcase_functions_config = {} self.testcase_request_config = {} self.testcase_shared_valiables_mapping = OrderedDict() # testcase config shall inherit from testset configs, # but can not change testset configs, that's why we use copy.deepcopy here. self.testcase_functions_config = copy.deepcopy( self.testcase_functions_config) self.testcase_variable_mapping = copy.deepcopy( self.testcase_shared_valiables_mapping) self.testcase_parser.bind_functions(self.testcase_functions_config) self.testcase_parser.update_binded_variables( self.testcase_variable_mapping) if level == "testset": self.import_module_items(["httprunner.built_in"], "testset")
def __init__(self): self.testset_shared_variables_mapping = OrderedDict() self.testcase_variables_mapping = OrderedDict() self.testcase_parser = testcase.TestcaseParser() self.init_context()
def __init__(self): self.testset_shared_variables_mapping = OrderedDict() self.testcase_variables_mapping = OrderedDict() self.testcase_parser = TestcaseParser() self.evaluated_validators = [] self.init_context()