支持上传文件相对路径
This commit is contained in:
parent
87586513b1
commit
e385aa81b4
|
@ -11,7 +11,7 @@ import requests
|
||||||
import simplejson
|
import simplejson
|
||||||
from requests_toolbelt import MultipartEncoder
|
from requests_toolbelt import MultipartEncoder
|
||||||
from comm.utils.readYaml import write_yaml_file, read_yaml_data
|
from comm.utils.readYaml import write_yaml_file, read_yaml_data
|
||||||
from config import API_CONFIG, PROJECT_NAME
|
from config import API_CONFIG, PROJECT_NAME, PAGE_DIR
|
||||||
|
|
||||||
|
|
||||||
def post(headers, address, mime_type, timeout=10, data=None, files=None, cookies=None):
|
def post(headers, address, mime_type, timeout=10, data=None, files=None, cookies=None):
|
||||||
|
@ -32,7 +32,11 @@ def post(headers, address, mime_type, timeout=10, data=None, files=None, cookies
|
||||||
value = files[key]
|
value = files[key]
|
||||||
# 判定参数值是否为文件,如果是则替换为二进制值
|
# 判定参数值是否为文件,如果是则替换为二进制值
|
||||||
if '/' in value:
|
if '/' in value:
|
||||||
files[key] = (os.path.basename(value), open(value, 'rb'))
|
if ':' in value:
|
||||||
|
file_path = value
|
||||||
|
else:
|
||||||
|
file_path = PAGE_DIR + value
|
||||||
|
files[key] = (os.path.basename(file_path), open(file_path, 'rb'))
|
||||||
enc = MultipartEncoder(
|
enc = MultipartEncoder(
|
||||||
fields=files,
|
fields=files,
|
||||||
boundary='--------------' + str(random.randint(1e28, 1e29-1))
|
boundary='--------------' + str(random.randint(1e28, 1e29-1))
|
||||||
|
|
|
@ -121,8 +121,9 @@ def init_premise(test_info, case_data, case_path):
|
||||||
|
|
||||||
# 获取当前接口期望结果:获取期望结果-获取关联值-替换关联值
|
# 获取当前接口期望结果:获取期望结果-获取关联值-替换关联值
|
||||||
expected_rs = read_json(case_data['summary'], case_data['check_body']['expected_result'], case_path)
|
expected_rs = read_json(case_data['summary'], case_data['check_body']['expected_result'], case_path)
|
||||||
parameter['data'] = data
|
msg_body = parameter.copy()
|
||||||
__relevance = readRelevance.get_relevance(parameter, expected_rs, __relevance)
|
msg_body['pre_response'] = data
|
||||||
|
__relevance = readRelevance.get_relevance(msg_body, expected_rs, __relevance)
|
||||||
expected_rs = replaceRelevance.replace(expected_rs, __relevance)
|
expected_rs = replaceRelevance.replace(expected_rs, __relevance)
|
||||||
case_data['check_body']['expected_result'] = expected_rs
|
case_data['check_body']['expected_result'] = expected_rs
|
||||||
logging.debug("期望返回处理结果:{}".format(case_data))
|
logging.debug("期望返回处理结果:{}".format(case_data))
|
||||||
|
|
Loading…
Reference in New Issue