mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-25 10:20:11 +08:00
hot plugin support: search variables recursive upward from testset file
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user