bugfix: when the bind value of variable is not in string type, it should be converted to string first, or it will raise TypeError in replace function

This commit is contained in:
httprunner
2017-07-31 21:04:19 +08:00
parent 46fe02a6cd
commit 233978007e
2 changed files with 34 additions and 5 deletions

View File

@@ -151,10 +151,16 @@ def parse_variables(content, variable_mapping):
raise ParamsError(
"%s is not defined in bind variables!" % variable_name)
content = content.replace(
"${}".format(variable_name),
variable_value
)
if "${}".format(variable_name) == content:
# content is a variable
content = variable_value
else:
# content contains one or many variables
content = content.replace(
"${}".format(variable_name),
str(variable_value)
)
return content
def is_functon(content):