rename excpetion module to exceptions

This commit is contained in:
debugtalk
2018-07-25 10:52:16 +08:00
parent 7478331cb5
commit 4a87af51e7
15 changed files with 94 additions and 94 deletions

View File

@@ -2,7 +2,7 @@ import os
import time
import requests
from httprunner import exception, response, runner, testcase
from httprunner import exceptions, response, runner, testcase
from httprunner.context import Context
from httprunner.utils import FileUtils, gen_md5
from tests.base import ApiServerUnittest
@@ -270,7 +270,7 @@ class VariableBindsUnittest(ApiServerUnittest):
]
self.context.bind_variables(variables)
with self.assertRaises(exception.ValidationFailure):
with self.assertRaises(exceptions.ValidationFailure):
self.context.validate(validators, resp_obj)
validators = [
@@ -305,7 +305,7 @@ class VariableBindsUnittest(ApiServerUnittest):
variables = []
self.context.bind_variables(variables)
with self.assertRaises(exception.ParamsError):
with self.assertRaises(exceptions.ParamsError):
self.context.validate(validators, resp_obj)
# expected value missed in variables mapping
@@ -314,5 +314,5 @@ class VariableBindsUnittest(ApiServerUnittest):
]
self.context.bind_variables(variables)
with self.assertRaises(exception.ValidationFailure):
with self.assertRaises(exceptions.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 FileNotFound
from httprunner.exceptions import FileNotFound
from tests.base import ApiServerUnittest

View File

@@ -1,5 +1,5 @@
import requests
from httprunner import exception, response, utils
from httprunner import exceptions, response, utils
from httprunner.compat import bytes
from tests.base import ApiServerUnittest
@@ -138,7 +138,7 @@ class TestResponse(ApiServerUnittest):
]
resp_obj = response.ResponseObject(resp)
with self.assertRaises(exception.ParseResponseFailure):
with self.assertRaises(exceptions.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.ParseResponseFailure):
with self.assertRaises(exceptions.ParseResponseFailure):
resp_obj.extract_response(extract_binds_list)
def test_extract_response_json_string(self):
@@ -202,7 +202,7 @@ class TestResponse(ApiServerUnittest):
{"resp_content_key1": "LB123.*RB789"}
]
resp_obj = response.ResponseObject(resp)
with self.assertRaises(exception.ParamsError):
with self.assertRaises(exceptions.ParamsError):
resp_obj.extract_response(extract_binds_list)
def test_extract_response_empty(self):
@@ -225,5 +225,5 @@ class TestResponse(ApiServerUnittest):
{"resp_content_body": "content.data.def"}
]
resp_obj = response.ResponseObject(resp)
with self.assertRaises(exception.ParseResponseFailure):
with self.assertRaises(exceptions.ParseResponseFailure):
resp_obj.extract_response(extract_binds_list)

View File

@@ -1,7 +1,7 @@
import os
import time
from httprunner import HttpRunner, exception, runner
from httprunner import HttpRunner, exceptions, runner
from httprunner.testcase import TestcaseLoader
from httprunner.utils import FileUtils, deep_update_dict
from tests.base import ApiServerUnittest
@@ -66,7 +66,7 @@ class TestRunner(ApiServerUnittest):
]
}
with self.assertRaises(exception.ValidationFailure):
with self.assertRaises(exceptions.ValidationFailure):
self.test_runner.run_test(test)
def test_run_testset_with_hooks(self):

View File

@@ -3,7 +3,7 @@ import time
import unittest
from httprunner import testcase
from httprunner.exception import ApiNotFound, ParamsError, SuiteNotFound
from httprunner.exceptions import ApiNotFound, ParamsError, SuiteNotFound
from httprunner.testcase import TestcaseLoader

View File

@@ -2,7 +2,7 @@ import os
import shutil
import unittest
from httprunner import exception, utils
from httprunner import exceptions, utils
from httprunner.compat import OrderedDict
from httprunner.utils import FileUtils
from tests.base import ApiServerUnittest
@@ -16,7 +16,7 @@ class TestFileUtils(unittest.TestCase):
with open(yaml_tmp_file, 'w') as f:
f.write("")
with self.assertRaises(exception.FileFormatError):
with self.assertRaises(exceptions.FileFormatError):
FileUtils._load_yaml_file(yaml_tmp_file)
os.remove(yaml_tmp_file)
@@ -25,7 +25,7 @@ class TestFileUtils(unittest.TestCase):
with open(yaml_tmp_file, 'w') as f:
f.write("abc")
with self.assertRaises(exception.FileFormatError):
with self.assertRaises(exceptions.FileFormatError):
FileUtils._load_yaml_file(yaml_tmp_file)
os.remove(yaml_tmp_file)
@@ -37,7 +37,7 @@ class TestFileUtils(unittest.TestCase):
with open(json_tmp_file, 'w') as f:
f.write("")
with self.assertRaises(exception.FileFormatError):
with self.assertRaises(exceptions.FileFormatError):
FileUtils._load_json_file(json_tmp_file)
os.remove(json_tmp_file)
@@ -46,7 +46,7 @@ class TestFileUtils(unittest.TestCase):
with open(json_tmp_file, 'w') as f:
f.write("{}")
with self.assertRaises(exception.FileFormatError):
with self.assertRaises(exceptions.FileFormatError):
FileUtils._load_json_file(json_tmp_file)
os.remove(json_tmp_file)
@@ -55,14 +55,14 @@ class TestFileUtils(unittest.TestCase):
with open(json_tmp_file, 'w') as f:
f.write("abc")
with self.assertRaises(exception.FileFormatError):
with self.assertRaises(exceptions.FileFormatError):
FileUtils._load_json_file(json_tmp_file)
os.remove(json_tmp_file)
def test_load_testcases_bad_filepath(self):
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/demo')
with self.assertRaises(exception.FileNotFound):
with self.assertRaises(exceptions.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.ParseResponseFailure):
with self.assertRaises(exceptions.ParseResponseFailure):
utils.query_json(json_content, query)
query = "ids.5"
with self.assertRaises(exception.ParseResponseFailure):
with self.assertRaises(exceptions.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.ParseResponseFailure):
with self.assertRaises(exceptions.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.ResponseFailure):
with self.assertRaises(exceptions.ResponseFailure):
utils.query_json(json_content, query)
json_content = "<html><body>content</body></html>"
query = "key"
with self.assertRaises(exception.ParseResponseFailure):
with self.assertRaises(exceptions.ParseResponseFailure):
utils.query_json(json_content, query)
def test_get_uniform_comparator(self):
@@ -302,7 +302,7 @@ class TestUtils(ApiServerUnittest):
self.assertIn("gen_md5", functions_dict)
self.assertNotIn("urllib", functions_dict)
with self.assertRaises(exception.FileNotFoundError):
with self.assertRaises(exceptions.FileNotFoundError):
utils.get_imported_module_from_file("tests/debugtalk2.py")
def test_search_conf_function(self):
@@ -314,10 +314,10 @@ class TestUtils(ApiServerUnittest):
self.assertTrue(utils.is_function(("_", gen_md5)))
self.assertEqual(gen_md5("abc"), "900150983cd24fb0d6963f7d28e17f72")
with self.assertRaises(exception.FunctionNotFound):
with self.assertRaises(exceptions.FunctionNotFound):
utils.search_conf_item("tests/data/subfolder/test.yml", "function", "func_not_exist")
with self.assertRaises(exception.FunctionNotFound):
with self.assertRaises(exceptions.FunctionNotFound):
utils.search_conf_item("/user/local/bin", "function", "gen_md5")
def test_search_conf_variable(self):
@@ -329,10 +329,10 @@ class TestUtils(ApiServerUnittest):
self.assertTrue(utils.is_variable(("SECRET_KEY", SECRET_KEY)))
self.assertEqual(SECRET_KEY, "DebugTalk")
with self.assertRaises(exception.VariableNotFound):
with self.assertRaises(exceptions.VariableNotFound):
utils.search_conf_item("tests/data/subfolder/test.yml", "variable", "variable_not_exist")
with self.assertRaises(exception.VariableNotFound):
with self.assertRaises(exceptions.VariableNotFound):
utils.search_conf_item("/user/local/bin", "variable", "SECRET_KEY")
def test_is_variable(self):
@@ -443,7 +443,7 @@ class TestUtils(ApiServerUnittest):
map_list = "invalid"
override_mapping = {"a": 3, "c": 4}
with self.assertRaises(exception.ParamsError):
with self.assertRaises(exceptions.ParamsError):
utils.override_variables_binds(map_list, override_mapping)
def test_create_scaffold(self):