mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +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(
|
||||
|
||||
@@ -186,17 +186,6 @@ class TestUtils(ApiServerUnittest):
|
||||
result = utils.query_json(json_content, query)
|
||||
self.assertEqual(result, "Leo")
|
||||
|
||||
def test_query_json_content_is_text(self):
|
||||
json_content = ""
|
||||
query = "key"
|
||||
with self.assertRaises(exceptions.ResponseFailure):
|
||||
utils.query_json(json_content, query)
|
||||
|
||||
json_content = "<html><body>content</body></html>"
|
||||
query = "key"
|
||||
with self.assertRaises(exceptions.ParseResponseFailure):
|
||||
utils.query_json(json_content, query)
|
||||
|
||||
def test_get_uniform_comparator(self):
|
||||
self.assertEqual(utils.get_uniform_comparator("eq"), "equals")
|
||||
self.assertEqual(utils.get_uniform_comparator("=="), "equals")
|
||||
|
||||
Reference in New Issue
Block a user