mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-11 10:49:43 +08:00
bugfix: when binding variable is None, it should be None other than raise ParamsError"
This commit is contained in:
@@ -118,15 +118,14 @@ class TestcaseParser(object):
|
|||||||
|
|
||||||
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":
|
||||||
item = self.functions_binds.get(item_name)
|
if item_name in self.functions_binds:
|
||||||
|
return self.functions_binds[item_name]
|
||||||
elif item_type == "variable":
|
elif item_type == "variable":
|
||||||
item = self.variables_binds.get(item_name)
|
if item_name in self.variables_binds:
|
||||||
|
return self.variables_binds[item_name]
|
||||||
else:
|
else:
|
||||||
raise exception.ParamsError("bind item should only be function or variable.")
|
raise exception.ParamsError("bind item should only be function or variable.")
|
||||||
|
|
||||||
if item:
|
|
||||||
return item
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
assert self.file_path is not None
|
assert self.file_path is not None
|
||||||
return utils.search_conf_item(self.file_path, item_type, item_name)
|
return utils.search_conf_item(self.file_path, item_type, item_name)
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ class TestcaseParserUnittest(unittest.TestCase):
|
|||||||
"var_2": "def",
|
"var_2": "def",
|
||||||
"var_3": 123,
|
"var_3": 123,
|
||||||
"var_4": {"a": 1},
|
"var_4": {"a": 1},
|
||||||
"var_5": True
|
"var_5": True,
|
||||||
|
"var_6": None
|
||||||
}
|
}
|
||||||
testcase_parser = testcase.TestcaseParser(variables_binds=variable_binds)
|
testcase_parser = testcase.TestcaseParser(variables_binds=variable_binds)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@@ -106,6 +107,10 @@ class TestcaseParserUnittest(unittest.TestCase):
|
|||||||
testcase_parser.eval_content_variables("abc$var_4"),
|
testcase_parser.eval_content_variables("abc$var_4"),
|
||||||
"abc{'a': 1}"
|
"abc{'a': 1}"
|
||||||
)
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
testcase_parser.eval_content_variables("$var_6"),
|
||||||
|
None
|
||||||
|
)
|
||||||
|
|
||||||
def test_eval_content_variables_search_upward(self):
|
def test_eval_content_variables_search_upward(self):
|
||||||
testcase_parser = testcase.TestcaseParser()
|
testcase_parser = testcase.TestcaseParser()
|
||||||
|
|||||||
Reference in New Issue
Block a user