提交 5b6c3939 编写于 作者: 泰斯特Test's avatar 泰斯特Test

[fix](interfaceTest/tester.py) 修复「请求参数」中部分全局变量未替换成功

上级 898fbe69
...@@ -4,7 +4,7 @@ import time ...@@ -4,7 +4,7 @@ import time
import datetime import datetime
import re import re
from utils import common from utils import common
import ast
from bson import ObjectId from bson import ObjectId
from threading import Thread from threading import Thread
...@@ -150,11 +150,17 @@ class tester: ...@@ -150,11 +150,17 @@ class tester:
url += '%s=%s&' % (key, value) url += '%s=%s&' % (key, value)
url = url[0:(len(url) - 1)] url = url[0:(len(url) - 1)]
elif 'presendParams' in test_case and isinstance(test_case['presendParams'], dict): elif 'presendParams' in test_case and isinstance(test_case['presendParams'], dict):
for key, value in test_case['presendParams'].items(): # dict 先转 str,方便全局变量替换
test_case['presendParams'][key] = \ test_case['presendParams'] = str(test_case['presendParams'])
common.resolve_global_var(pre_resolve_var=value, global_var_dic=self.global_vars) \
if isinstance(value, str) else test_case['presendParams'][key] # 全局替换
test_case['presendParams'] = common.resolve_global_var(pre_resolve_var=test_case['presendParams'],
global_var_dic=self.global_vars)
# 转回 dict
test_case['presendParams'] = ast.literal_eval(test_case['presendParams'])
json_data = test_case['presendParams'] json_data = test_case['presendParams']
if 'headers' in test_case and not test_case['headers'] in ["", None, {}, {'': ''}]: if 'headers' in test_case and not test_case['headers'] in ["", None, {}, {'': ''}]:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册