mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-13 03:39:44 +08:00
make wrappers for get_bind_item
This commit is contained in:
@@ -209,7 +209,7 @@ class Context(object):
|
|||||||
""" validate with functions
|
""" validate with functions
|
||||||
"""
|
"""
|
||||||
comparator = utils.get_uniform_comparator(validator_dict["comparator"])
|
comparator = utils.get_uniform_comparator(validator_dict["comparator"])
|
||||||
validate_func = self.testcase_parser.get_bind_item("function", comparator)
|
validate_func = self.testcase_parser.get_bind_function(comparator)
|
||||||
|
|
||||||
if not validate_func:
|
if not validate_func:
|
||||||
raise exception.FunctionNotFound("comparator not found: {}".format(comparator))
|
raise exception.FunctionNotFound("comparator not found: {}".format(comparator))
|
||||||
|
|||||||
@@ -718,7 +718,7 @@ class TestcaseParser(object):
|
|||||||
"""
|
"""
|
||||||
self.functions = functions
|
self.functions = functions
|
||||||
|
|
||||||
def get_bind_item(self, item_type, item_name):
|
def _get_bind_item(self, item_type, item_name):
|
||||||
if item_type == "function":
|
if item_type == "function":
|
||||||
if item_name in self.functions:
|
if item_name in self.functions:
|
||||||
return self.functions[item_name]
|
return self.functions[item_name]
|
||||||
@@ -745,6 +745,12 @@ class TestcaseParser(object):
|
|||||||
raise exception.ParamsError(
|
raise exception.ParamsError(
|
||||||
"{} is not defined in bind {}s!".format(item_name, item_type))
|
"{} is not defined in bind {}s!".format(item_name, item_type))
|
||||||
|
|
||||||
|
def get_bind_function(self, func_name):
|
||||||
|
return self._get_bind_item("function", func_name)
|
||||||
|
|
||||||
|
def get_bind_variable(self, variable_name):
|
||||||
|
return self._get_bind_item("variable", variable_name)
|
||||||
|
|
||||||
def parameterize(self, csv_file_name, fetch_method="Sequential"):
|
def parameterize(self, csv_file_name, fetch_method="Sequential"):
|
||||||
parameter_file_path = os.path.join(
|
parameter_file_path = os.path.join(
|
||||||
os.path.dirname(self.file_path),
|
os.path.dirname(self.file_path),
|
||||||
@@ -771,7 +777,7 @@ class TestcaseParser(object):
|
|||||||
if func_name in ["parameterize", "P"]:
|
if func_name in ["parameterize", "P"]:
|
||||||
eval_value = self.parameterize(*args, **kwargs)
|
eval_value = self.parameterize(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
func = self.get_bind_item("function", func_name)
|
func = self.get_bind_function(func_name)
|
||||||
eval_value = func(*args, **kwargs)
|
eval_value = func(*args, **kwargs)
|
||||||
|
|
||||||
func_content = "${" + func_content + "}"
|
func_content = "${" + func_content + "}"
|
||||||
@@ -804,7 +810,7 @@ class TestcaseParser(object):
|
|||||||
"""
|
"""
|
||||||
variables_list = extract_variables(content)
|
variables_list = extract_variables(content)
|
||||||
for variable_name in variables_list:
|
for variable_name in variables_list:
|
||||||
variable_value = self.get_bind_item("variable", variable_name)
|
variable_value = self.get_bind_variable(variable_name)
|
||||||
|
|
||||||
if "${}".format(variable_name) == content:
|
if "${}".format(variable_name) == content:
|
||||||
# content is a variable
|
# content is a variable
|
||||||
|
|||||||
Reference in New Issue
Block a user