mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-07 00:39:34 +08:00
bugfix: set repsonse attribute
This commit is contained in:
@@ -18,6 +18,7 @@ class ResponseObject(object):
|
||||
@param (requests.Response instance) resp_obj
|
||||
"""
|
||||
self.resp_obj = resp_obj
|
||||
self.attributes = {}
|
||||
|
||||
def __getattr__(self, key):
|
||||
try:
|
||||
@@ -152,6 +153,21 @@ class ResponseObject(object):
|
||||
logger.log_error(err_msg)
|
||||
raise exceptions.ExtractFailure(err_msg)
|
||||
|
||||
# new set response attributes
|
||||
elif top_query == "attributes":
|
||||
if not sub_query:
|
||||
# extract response attributes
|
||||
return self.attributes
|
||||
|
||||
if sub_query in self.attributes:
|
||||
return self.attributes[sub_query]
|
||||
else:
|
||||
# content = "attributes.new_attribute_not_exist"
|
||||
err_msg = u"Failed to extract cumstom set attribute! => {}\n".format(field)
|
||||
err_msg += u"response set attributes: {}\n".format(self.attributes)
|
||||
logger.log_error(err_msg)
|
||||
raise exceptions.ExtractFailure(err_msg)
|
||||
|
||||
# others
|
||||
else:
|
||||
err_msg = u"Failed to extract attribute from response! => {}\n".format(field)
|
||||
|
||||
Reference in New Issue
Block a user