mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-14 20:29:44 +08:00
remove exception type: ResponseFailure
This commit is contained in:
@@ -12,9 +12,6 @@ class MyBaseFailure(BaseException):
|
||||
class ValidationFailure(MyBaseFailure):
|
||||
pass
|
||||
|
||||
class ResponseFailure(MyBaseFailure):
|
||||
pass
|
||||
|
||||
class ParseResponseFailure(MyBaseFailure):
|
||||
pass
|
||||
|
||||
|
||||
@@ -183,8 +183,8 @@ class Runner(object):
|
||||
validators = testcase_dict.get("validate", []) or testcase_dict.get("validators", [])
|
||||
try:
|
||||
self.context.validate(validators, resp_obj)
|
||||
except (exceptions.ParamsError, exceptions.ResponseFailure, \
|
||||
exceptions.ValidationFailure, exceptions.ParseResponseFailure):
|
||||
except (exceptions.ParamsError, \
|
||||
exceptions.ValidationFailure, exceptions.ParseResponseFailure):
|
||||
# log request
|
||||
err_req_msg = "request: \n"
|
||||
err_req_msg += "headers: {}\n".format(parsed_request.pop("headers", {}))
|
||||
|
||||
@@ -172,7 +172,7 @@ class FileUtils(object):
|
||||
|
||||
def query_json(json_content, query, delimiter='.'):
|
||||
""" Do an xpath-like query with json_content.
|
||||
@param (json_content) json_content
|
||||
@param (dict/list) json_content
|
||||
json_content = {
|
||||
"ids": [1, 2, 3, 4],
|
||||
"person": {
|
||||
@@ -189,14 +189,11 @@ def query_json(json_content, query, delimiter='.'):
|
||||
"person.cities.0" => "Guangzhou"
|
||||
@return queried result
|
||||
"""
|
||||
if json_content == "":
|
||||
raise exceptions.ResponseFailure("response content is empty!")
|
||||
|
||||
try:
|
||||
for key in query.split(delimiter):
|
||||
if isinstance(json_content, list):
|
||||
json_content = json_content[int(key)]
|
||||
elif isinstance(json_content, (dict, CaseInsensitiveDict)):
|
||||
elif isinstance(json_content, dict):
|
||||
json_content = json_content[key]
|
||||
else:
|
||||
raise exceptions.ParseResponseFailure(
|
||||
|
||||
Reference in New Issue
Block a user