htprunner3.1.5版本的参数化传参无法解析参数问题
比如
class Test_add(HttpRunner):
@pytest.mark.parametrize('param',Parameters({'age':['$myage']}))
def test_start(self, param):
super().test_start(param)
上例中参数化时用到teststeps中step1提取的返回结果,动态入参到参数化$myage,运行会报错myage未定义,实际上日志也确实打印出了提取成功,
因为在参数解析时源码有bug需要修改parser.py文件钟的parse_string函数,对应部分修改如下
# search variable like ${var} or $var
var_match = variable_regex_compile.match(raw_string, match_start_position)
if var_match:
var_name = var_match.group(1) or var_match.group(2)
var_value = get_mapping_variable(var_name, variables_mapping)
#llf解析参数化时上一个接口返回的参数
while True:
try:
match_start_position = var_value.index("$", 0)
var_value = parse_data(var_value, variables_mapping, functions_mapping)
except:
break
return var_value
if f"${var_name}" == raw_string or "${" + var_name + "}" == raw_string:
# raw_string is a variable, $var or ${var}, return its value directly
# res=get_mapping_variable(var_value,variables_mapping)
return var_value
# return res