mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-15 20:38:44 +08:00
refactor variable context:
1, variable context has two level, testset and testcase; 2, testset level variables can be used in whole test suite, while testcase level variables can only be used in testcase; 3, when variable binds with functions, the funtions will be called and the result will be set to the variable.
This commit is contained in:
@@ -45,7 +45,7 @@ class Runner(object):
|
||||
self.context.import_module_functions(module_functions, level)
|
||||
|
||||
variable_binds = config_dict.get('variable_binds', [])
|
||||
self.context.register_variables_config(variable_binds, level)
|
||||
self.context.bind_variables(variable_binds, level)
|
||||
|
||||
request_config = config_dict.get('request', {})
|
||||
if level == "testset":
|
||||
@@ -93,8 +93,8 @@ class Runner(object):
|
||||
resp_obj = response.ResponseObject(resp)
|
||||
|
||||
extract_binds = testcase.get("extract_binds", {})
|
||||
extracted_variables_mapping = resp_obj.extract_response(extract_binds)
|
||||
self.context.bind_extracted_variables(extracted_variables_mapping)
|
||||
extracted_variables_mapping_list = resp_obj.extract_response(extract_binds)
|
||||
self.context.bind_variables(extracted_variables_mapping_list, level="testset")
|
||||
|
||||
validators = testcase.get("validators", [])
|
||||
diff_content_list = resp_obj.validate(
|
||||
|
||||
Reference in New Issue
Block a user