apitest_unittest/scripts/prepost_script_安全纯净大屏_2.py

24 lines
748 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

def setup(request):
"""前置脚本处理请求对象的逻辑代码"""
# rquest 对象输出如下:
"""{'Run': 'YES', 'Time': 1,
'Url': '/auth/loginByNotBip',
'Headers': '{"Content-Type": "application/json"}',
'Params': None,
'Request Data': '{"account": "{{account}}", "password": "{{passwd}}"}',
'Expected': None,
'Response': '',
'Assertion': '',
'Error log': '',
None: None}"""
# 获取请求参数
request.get("Request Data") # 获取到的结果是一个json字符串使用需要转字典
return request
def teardown(response):
# print(f"执行后置代码片段处理:{response.json}")
"""后置脚本处理响应对象的逻辑代码"""
return response