增加eval`` 语法糖,可在用例中书写,内部会使用eval函数处理``中间的表达式内容,会优先处理&$.uid&类似的jsonpath语法糖

This commit is contained in:
zy7y 2021-01-27 14:19:29 +08:00
parent 9706f6cd1d
commit b6ddb1df9e
3 changed files with 7 additions and 0 deletions

View File

@ -140,6 +140,10 @@ https://www.bilibili.com/video/BV1EE411B7SU?p=10
> 详细内容见代码注释`tools/data_clearing.py`
> 如不需要使用该功能请做如下处理,如也不使用数据库对象,只需参考 https://gitee.com/zy7y/apiAutoTest/issues/I2BAQL 修改即可
![](https://gitee.com/zy7y/blog_images/raw/master/img/20210119184856.png)
2021/01/27 添加eval语法糖请求数据需要上个接口返回的id+1实现基本的数学预算使用形式具体查看excel用例文件及用例描述页与报告对着看
![](https://gitee.com/zy7y/blog_images/raw/master/img/20210127141257.png)
#### 博客园首发
https://www.cnblogs.com/zy7y/p/13426816.html

Binary file not shown.

View File

@ -40,6 +40,9 @@ def rep_expr(content: str, data: dict, expr: str = '&(.*?)&') -> str:
"""
for ctt in re.findall(expr, content):
content = content.replace(f'&{ctt}&', str(extractor(data, ctt)))
# 解决运算问题,实现+ -等常规数学运算, 用例书写格式{"uid":eval`&$.pid&+1`} 如果需要是字符串{"uid":eval`&$.pid&+1`}
for e in re.findall('eval`(.*)`', content):
content = content.replace(f'eval`{e}`', str(eval(e)))
return content