This commit is contained in:
jing song 2022-01-19 14:03:51 +08:00
parent 2f2d8a3c44
commit 7cd7a6117b
4 changed files with 18 additions and 34 deletions

2
.gitignore vendored
View File

@ -2,7 +2,7 @@ venv
.idea .idea
__pycache__/ __pycache__/
logs/ logs/
./report/ /report/
.pytest_cache/ .pytest_cache/
config/config.ini config/config.ini
caches caches

View File

@ -55,8 +55,8 @@ class apiSend(object):
allure.attach(name="请求地址", body=url) allure.attach(name="请求地址", body=url)
allure.attach(name="请求头", body=str(header)) allure.attach(name="请求头", body=str(header))
allure.attach(name="请求参数", body=str(data_random)) allure.attach(name="请求参数", body=str(data_random))
if "multipart/form-data" in header.values(): if "multipart/form-data" in str(header.values()):
if files is not None: if isinstance(files,dict):
for i in files: for i in files:
value = files[i] value = files[i]
if isinstance(value, int): if isinstance(value, int):
@ -72,11 +72,13 @@ class apiSend(object):
boundary='-----------------------------' + str(random.randint(int(1e28), int(1e29 - 1))) boundary='-----------------------------' + str(random.randint(int(1e28), int(1e29 - 1)))
) )
header['Content-Type'] = multipart.content_type header['Content-Type'] = multipart.content_type
response = requests.post(url=url, data=data, headers=header, timeout=timeout) response = requests.post(url=url, headers=header, timeout=timeout,data=multipart)
else: elif files is None:
multipart = MultipartEncoder(data) multipart = MultipartEncoder(data)
response = requests.post(url=url, data=multipart, headers={'Content-Type': multipart.content_type}, response = requests.post(url=url, data=multipart, headers={'Content-Type': multipart.content_type},
timeout=timeout) timeout=timeout)
else:
raise TypeError("files参数格式错误")
elif 'application/json' in header.values(): elif 'application/json' in header.values():
if data_random: if data_random:
data_random = json.loads(data_random) data_random = json.loads(data_random)

View File

@ -1,27 +0,0 @@
allure-pytest==2.9.43
allure-python-commons==2.9.43
atomicwrites==1.4.0
attrs==21.2.0
certifi==2021.5.30
chardet==4.0.0
colorama==0.4.4
coverage==5.5
DingtalkChatbot==1.5.3
idna==2.10
iniconfig==1.1.1
jsonpath==0.82
packaging==20.9
pluggy==0.13.1
py==1.10.0
PyMySQL==1.0.2
pyparsing==2.4.7
pytest==6.2.4
pytest-ordering==0.6
pytest-rerunfailures==10.0
PyYAML==5.4.1
requests==2.25.1
requests-toolbelt==0.9.1
simplejson==3.17.2
six==1.16.0
toml==0.10.2
urllib3==1.26.5

View File

@ -4,7 +4,7 @@ import os
from config.confManage import dir_manage from config.confManage import dir_manage
from scripts.readYamlFile import ini_yaml from scripts.readYamlFile import ini_yaml
from scripts import root_path from scripts import root_path
import time
def getFilePathList(rootpath, filetype): def getFilePathList(rootpath, filetype):
filepath = [] filepath = []
@ -35,8 +35,17 @@ def write_case():
if not os.path.exists(casepath + midp): if not os.path.exists(casepath + midp):
os.makedirs(casepath + midp) os.makedirs(casepath + midp)
if not os.path.exists(case): if not os.path.exists(case):
t1 =time.strftime("%Y/%m/%d %H:%M")
with open(case, 'w', encoding='utf-8') as f: with open(case, 'w', encoding='utf-8') as f:
f.write(f"""from test_suite.testcase.{testname} import * f.write(f"""# coding:utf-8
\"\"\"
@author: jing
@contact: 529548204@qq.com
@file: test_{filename}.py
@time: {t1}
\"\"\"
from test_suite.testcase.{testname} import *
paramData = ini_yaml("{file}") paramData = ini_yaml("{file}")