mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-18 18:17:35 +08:00
support validate with response time
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
__title__ = 'HttpRunner'
|
||||
__description__ = 'One-stop solution for HTTP(S) testing.'
|
||||
__url__ = 'https://github.com/HttpRunner/HttpRunner'
|
||||
__version__ = '1.5.5'
|
||||
__version__ = '1.5.6'
|
||||
__author__ = 'debugtalk'
|
||||
__author_email__ = 'mail@debugtalk.com'
|
||||
__license__ = 'MIT'
|
||||
|
||||
@@ -82,6 +82,16 @@ class ResponseObject(object):
|
||||
err_msg += u"attribute: {}".format(sub_query)
|
||||
logger.log_error(err_msg)
|
||||
raise exception.ParamsError(err_msg)
|
||||
elif top_query == "elapsed":
|
||||
if sub_query in ["days", "seconds", "microseconds"]:
|
||||
return getattr(self.elapsed, sub_query)
|
||||
elif sub_query == "total_seconds":
|
||||
return self.elapsed.total_seconds()
|
||||
else:
|
||||
err_msg = "{}: {} is not valid timedelta attribute.\n".format(field, sub_query)
|
||||
err_msg += "elapsed only support attributes: days, seconds, microseconds, total_seconds.\n"
|
||||
logger.log_error(err_msg)
|
||||
raise exception.ParamsError(err_msg)
|
||||
|
||||
try:
|
||||
top_query_content = getattr(self, top_query)
|
||||
@@ -96,11 +106,11 @@ class ResponseObject(object):
|
||||
# TODO: remove compatibility for content, text
|
||||
if isinstance(top_query_content, bytes):
|
||||
top_query_content = top_query_content.decode("utf-8")
|
||||
|
||||
|
||||
if isinstance(top_query_content, PreparedRequest):
|
||||
top_query_content = top_query_content.__dict__
|
||||
else:
|
||||
top_query_content = json.loads(top_query_content)
|
||||
else:
|
||||
top_query_content = json.loads(top_query_content)
|
||||
except json.decoder.JSONDecodeError:
|
||||
err_msg = u"Failed to extract data with delimiter!\n"
|
||||
err_msg += u"response content: {}\n".format(self.content)
|
||||
|
||||
Reference in New Issue
Block a user