1. 增加测试数据分析预警机制 2. 优化自动生成测试用例方法 3. 将用例跳过方法 提取成公共的fixture,自动运行 4. 修改pytet-html测试报告列’用例描述’值获取 5. 根 据最新修改,更新readme文件~
This commit is contained in:
@@ -37,7 +37,7 @@ class BaseRequest:
|
||||
f"请求方式: {req_data.get('method', None)}\n" \
|
||||
f"请求头: {req_data.get('headers', None)}\n" \
|
||||
f"请求Cookies: {req_data.get('cookies', None)}\n" \
|
||||
f"请求关键字: {req_data.get('pk', None)}\n" \
|
||||
f"请求关键字: {req_data.get('request_type', None)}\n" \
|
||||
f"请求内容: {req_data.get('payload', None)}\n" \
|
||||
f"请求文件: {req_data.get('files', None)}\n" \
|
||||
"=====================================================")
|
||||
@@ -48,14 +48,14 @@ class BaseRequest:
|
||||
f"请求方式: {req_data.get('method', None)}\n" \
|
||||
f"请求头: {req_data.get('headers', None)}\n" \
|
||||
f"请求Cookies: {req_data.get('cookies', None)}\n" \
|
||||
f"请求关键字: {req_data.get('pk', None)}\n" \
|
||||
f"请求关键字: {req_data.get('request_type', None)}\n" \
|
||||
f"请求内容: {req_data.get('payload', None)}\n" \
|
||||
f"请求文件: {req_data.get('files', None)}\n" \
|
||||
"=====================================================")
|
||||
res = cls.send_api_request(
|
||||
url=req_data.get("url"),
|
||||
method=req_data.get("method").lower(),
|
||||
pk=req_data.get("pk", None),
|
||||
request_type=req_data.get("request_type", None),
|
||||
header=req_data.get("headers", None),
|
||||
payload=req_data.get("payload", None),
|
||||
files=req_data.get("files", None),
|
||||
@@ -79,13 +79,13 @@ class BaseRequest:
|
||||
return res
|
||||
|
||||
@classmethod
|
||||
def send_api_request(cls, url: str, method: str, pk: str, header: Dict[str, str] = None, payload=None,
|
||||
def send_api_request(cls, url: str, method: str, request_type: str, header: Dict[str, str] = None, payload=None,
|
||||
files=None, cookies=None) -> Response:
|
||||
"""
|
||||
发送请求
|
||||
:param method: 请求方法
|
||||
:param url: 请求url
|
||||
:param pk: 请求参数类型,可选值为params,json,data
|
||||
:param request_type: 请求参数类型,可选值为params,json,data
|
||||
:param payload: 请求数据,对于不同请求类型,可以为dict,MultipartEncoder等
|
||||
:param files: 请求上传的文件
|
||||
:param header: 请求头
|
||||
@@ -95,9 +95,9 @@ class BaseRequest:
|
||||
headers = header or {}
|
||||
session = cls.get_session()
|
||||
|
||||
if pk and pk.lower() == 'params':
|
||||
if request_type and request_type.lower() == 'params':
|
||||
res = session.request(method=method, url=url, params=payload, headers=headers, cookies=cookies, timeout=5)
|
||||
elif pk and pk.lower() == 'data':
|
||||
elif request_type and request_type.lower() == 'data':
|
||||
if files:
|
||||
if not isinstance(files, dict):
|
||||
raise ValueError('data参数必须为dict')
|
||||
@@ -108,7 +108,7 @@ class BaseRequest:
|
||||
else:
|
||||
headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||
res = session.request(method=method, url=url, data=payload, headers=headers, cookies=cookies, timeout=5)
|
||||
elif pk and pk.lower() == 'json':
|
||||
elif request_type and request_type.lower() == 'json':
|
||||
if files:
|
||||
if not isinstance(files, dict):
|
||||
raise ValueError('json参数必须为dict')
|
||||
@@ -120,8 +120,8 @@ class BaseRequest:
|
||||
headers['Content-Type'] = 'application/json'
|
||||
res = session.request(method=method, url=url, json=payload, headers=headers, cookies=cookies, timeout=5)
|
||||
else:
|
||||
logger.error('pk可选关键字为params, json, data')
|
||||
print('pk可选关键字为params, json, data')
|
||||
raise ValueError('pk可选关键字为params, json, data')
|
||||
logger.error('request_type可选关键字为params, json, data')
|
||||
print('request_type可选关键字为params, json, data')
|
||||
raise ValueError('request_type可选关键字为params, json, data')
|
||||
|
||||
return res
|
||||
|
||||
@@ -26,6 +26,7 @@ def data_replace(content, source):
|
||||
return None
|
||||
logger.debug("\n======================================================\n" \
|
||||
"-------------Start:数据替换--------------------\n"
|
||||
f"替换源: {source}\n" \
|
||||
f"初始字符串: {content}\n" \
|
||||
"=====================================================")
|
||||
print(f"-----Start-----数据替换: 初始字符串为:{content}")
|
||||
|
||||
@@ -15,4 +15,18 @@ def add_docstring(docstring):
|
||||
func.__doc__ = docstring
|
||||
return func
|
||||
|
||||
return decorator
|
||||
return decorator
|
||||
|
||||
|
||||
class AddCLassDocstring:
|
||||
"""
|
||||
类装饰器,它接受一个字符串参数docstring,
|
||||
并返回一个装饰器函数。装饰器函数接受一个函数参数func,
|
||||
并将func的__doc__属性设置为docstring。
|
||||
"""
|
||||
def __init__(self, docstring):
|
||||
self.docstring = docstring
|
||||
|
||||
def __call__(self, func):
|
||||
func.__doc__ = self.docstring
|
||||
return func
|
||||
Reference in New Issue
Block a user