group exceptions to 2 types: failure and error

This commit is contained in:
debugtalk
2018-07-25 10:40:20 +08:00
parent 7a2920fac2
commit 7478331cb5
12 changed files with 60 additions and 54 deletions

View File

@@ -270,7 +270,7 @@ class VariableBindsUnittest(ApiServerUnittest):
]
self.context.bind_variables(variables)
with self.assertRaises(exception.ValidationError):
with self.assertRaises(exception.ValidationFailure):
self.context.validate(validators, resp_obj)
validators = [
@@ -314,5 +314,5 @@ class VariableBindsUnittest(ApiServerUnittest):
]
self.context.bind_variables(variables)
with self.assertRaises(exception.ValidationError):
with self.assertRaises(exception.ValidationFailure):
self.context.validate(validators, resp_obj)

View File

@@ -2,7 +2,7 @@ import os
import shutil
from httprunner import HttpRunner
from httprunner.exception import FileNotFoundError
from httprunner.exception import FileNotFound
from tests.base import ApiServerUnittest
@@ -163,5 +163,5 @@ class TestHttpRunner(ApiServerUnittest):
self.assertEqual(os.environ["UserName"], "debugtalk")
def test_load_env_path_not_exist(self):
with self.assertRaises(FileNotFoundError):
with self.assertRaises(FileNotFound):
HttpRunner(dot_env_path="not_exist.env").run(self.testset_path)

View File

@@ -138,7 +138,7 @@ class TestResponse(ApiServerUnittest):
]
resp_obj = response.ResponseObject(resp)
with self.assertRaises(exception.ParseResponseError):
with self.assertRaises(exception.ParseResponseFailure):
resp_obj.extract_response(extract_binds_list)
extract_binds_list = [
@@ -146,7 +146,7 @@ class TestResponse(ApiServerUnittest):
]
resp_obj = response.ResponseObject(resp)
with self.assertRaises(exception.ParseResponseError):
with self.assertRaises(exception.ParseResponseFailure):
resp_obj.extract_response(extract_binds_list)
def test_extract_response_json_string(self):
@@ -225,5 +225,5 @@ class TestResponse(ApiServerUnittest):
{"resp_content_body": "content.data.def"}
]
resp_obj = response.ResponseObject(resp)
with self.assertRaises(exception.ParseResponseError):
with self.assertRaises(exception.ParseResponseFailure):
resp_obj.extract_response(extract_binds_list)

View File

@@ -66,7 +66,7 @@ class TestRunner(ApiServerUnittest):
]
}
with self.assertRaises(exception.ValidationError):
with self.assertRaises(exception.ValidationFailure):
self.test_runner.run_test(test)
def test_run_testset_with_hooks(self):

View File

@@ -3,9 +3,7 @@ import time
import unittest
from httprunner import testcase
from httprunner.exception import (ApiNotFound, FileFormatError,
FileNotFoundError, ParamsError,
SuiteNotFound)
from httprunner.exception import ApiNotFound, ParamsError, SuiteNotFound
from httprunner.testcase import TestcaseLoader

View File

@@ -62,7 +62,7 @@ class TestFileUtils(unittest.TestCase):
def test_load_testcases_bad_filepath(self):
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/demo')
with self.assertRaises(exception.FileNotFoundError):
with self.assertRaises(exception.FileNotFound):
FileUtils.load_file(testcase_file_path)
def test_load_json_testcases(self):
@@ -163,11 +163,11 @@ class TestUtils(ApiServerUnittest):
self.assertEqual(result, 3)
query = "ids.str_key"
with self.assertRaises(exception.ParseResponseError):
with self.assertRaises(exception.ParseResponseFailure):
utils.query_json(json_content, query)
query = "ids.5"
with self.assertRaises(exception.ParseResponseError):
with self.assertRaises(exception.ParseResponseFailure):
utils.query_json(json_content, query)
query = "person.age"
@@ -175,7 +175,7 @@ class TestUtils(ApiServerUnittest):
self.assertEqual(result, 29)
query = "person.not_exist_key"
with self.assertRaises(exception.ParseResponseError):
with self.assertRaises(exception.ParseResponseFailure):
utils.query_json(json_content, query)
query = "person.cities.0"
@@ -189,12 +189,12 @@ class TestUtils(ApiServerUnittest):
def test_query_json_content_is_text(self):
json_content = ""
query = "key"
with self.assertRaises(exception.ResponseError):
with self.assertRaises(exception.ResponseFailure):
utils.query_json(json_content, query)
json_content = "<html><body>content</body></html>"
query = "key"
with self.assertRaises(exception.ParseResponseError):
with self.assertRaises(exception.ParseResponseFailure):
utils.query_json(json_content, query)
def test_get_uniform_comparator(self):