Skip to content

Commit

Permalink
api用例后置脚本支持通过res_request获取接口请求内容
Browse files Browse the repository at this point in the history
  • Loading branch information
Chras-fu committed Nov 1, 2023
1 parent c17b36b commit ab6aae4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/api/teststep.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, test, session, collector, context, params):
self.params = params
self.test = test
self.status_code = None
self.response_request = None
self.response_headers = None
self.response_content = None
self.response_content_bytes = None
Expand Down Expand Up @@ -79,6 +80,7 @@ def execute(self):
else:
res = request(self.collector.method, url, **self.collector.others)
end_time = datetime.datetime.now()
self.response_request = res.request
self.test.recordTransDuring(int((end_time-start_time).microseconds/1000))
self.save_response(res)
response_log = '【响应信息】:<br>'
Expand Down Expand Up @@ -157,6 +159,7 @@ def sys_get(name):
raise KeyError("不存在的公共参数或关联变量: {}".format(name))

names = locals()
names["res_request"] = self.response_request
names["res_code"] = self.status_code
names["res_header"] = self.response_headers
names["res_data"] = self.response_content
Expand Down

0 comments on commit ab6aae4

Please sign in to comment.