rename keyword: variable_binds => variables

This commit is contained in:
debugtalk
2017-10-24 15:59:09 +08:00
parent 7b64b8233b
commit 388a6da23a
14 changed files with 74 additions and 73 deletions

View File

@@ -54,8 +54,9 @@ class Context(object):
or config_dict.get('import_module_functions', [])
self.import_module_items(module_items, level)
variable_binds = config_dict.get('variable_binds', OrderedDict())
self.bind_variables(variable_binds, level)
variables = config_dict.get('variables') \
or config_dict.get('variable_binds', OrderedDict())
self.bind_variables(variables, level)
def import_requires(self, modules):
""" import required modules dynamically
@@ -92,11 +93,11 @@ class Context(object):
imported_variables_dict = utils.filter_module(imported_module, "variable")
self.bind_variables(imported_variables_dict, level)
def bind_variables(self, variable_binds, level="testcase"):
def bind_variables(self, variables, level="testcase"):
""" bind variables to testset context or current testcase context.
variables in testset context can be used in all testcases of current test suite.
@param (list or OrderDict) variable_binds, variable can be value or custom function.
@param (list or OrderDict) variables, variable can be value or custom function.
if value is function, it will be called and bind result to variable.
e.g.
OrderDict({
@@ -106,10 +107,10 @@ class Context(object):
"md5": "${gen_md5($TOKEN, $json, $random)}"
})
"""
if isinstance(variable_binds, list):
variable_binds = utils.convert_to_order_dict(variable_binds)
if isinstance(variables, list):
variables = utils.convert_to_order_dict(variables)
for variable_name, value in variable_binds.items():
for variable_name, value in variables.items():
variable_evale_value = self.testcase_parser.parse_content_with_bindings(value)
if level == "testset":