hot plugin support: search variables recursive upward from testset file

This commit is contained in:
debugtalk
2017-09-04 11:18:53 +08:00
parent 77047f3671
commit 082a2711e9
6 changed files with 25 additions and 15 deletions

View File

@@ -1 +1 @@
__version__ = '0.6.0'
__version__ = '0.6.1'

View File

@@ -39,7 +39,7 @@ class Context(object):
self.testcase_parser.bind_variables(self.testcase_variables_mapping)
if level == "testset":
self.import_module_functions(["ate.built_in"], "testset")
self.import_module_items(["ate.built_in"], "testset")
def import_requires(self, modules):
""" import required modules dynamicly
@@ -64,7 +64,7 @@ class Context(object):
self.__update_context_functions_config(level, eval_function_binds)
def import_module_functions(self, modules, level="testcase"):
def import_module_items(self, modules, level="testcase"):
""" import modules and bind all functions within the context
"""
sys.path.insert(0, os.getcwd())
@@ -73,6 +73,10 @@ class Context(object):
imported_functions_dict = utils.filter_module(imported_module, "function")
self.__update_context_functions_config(level, imported_functions_dict)
imported_variables_dict = utils.filter_module(imported_module, "variable")
variable_binds = [{key: value} for key, value in imported_variables_dict.items()]
self.bind_variables(variable_binds, level)
def bind_variables(self, variable_binds, 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.

View File

@@ -25,7 +25,7 @@ class Runner(object):
"lambda *str_args: hashlib.md5(''.join(str_args).\
encode('utf-8')).hexdigest()"
},
"import_module_functions": ["test.data.debugtalk"],
"import_module_items": ["test.data.debugtalk"],
"variable_binds": [
{"TOKEN": "debugtalk"},
{"random": "${gen_random_string(5)}"},
@@ -41,8 +41,10 @@ class Runner(object):
function_binds = config_dict.get('function_binds', {})
self.context.bind_functions(function_binds, level)
module_functions = config_dict.get('import_module_functions', [])
self.context.import_module_functions(module_functions, level)
# import_module_functions will be deprecated soon
module_items = config_dict.get('import_module_items', []) \
or config_dict.get('import_module_functions', [])
self.context.import_module_items(module_items, level)
variable_binds = config_dict.get('variable_binds', [])
self.context.bind_variables(variable_binds, level)