Add a simple test and all of the args.
This commit is contained in:
@@ -27,10 +27,18 @@ class _Error(Exception):
|
|||||||
schema_path=(),
|
schema_path=(),
|
||||||
parent=None,
|
parent=None,
|
||||||
):
|
):
|
||||||
# Calling __init__ is important, because otherwise __reduce__ will
|
super(_Error, self).__init__(
|
||||||
# return empty args tuple on Py2.7 and unpickling will fail because
|
message,
|
||||||
# init requires at least one argument.
|
validator,
|
||||||
super(_Error, self).__init__(message)
|
path,
|
||||||
|
cause,
|
||||||
|
context,
|
||||||
|
validator_value,
|
||||||
|
instance,
|
||||||
|
schema,
|
||||||
|
schema_path,
|
||||||
|
parent,
|
||||||
|
)
|
||||||
self.message = message
|
self.message = message
|
||||||
self.path = self.relative_path = deque(path)
|
self.path = self.relative_path = deque(path)
|
||||||
self.schema_path = self.relative_schema_path = deque(schema_path)
|
self.schema_path = self.relative_schema_path = deque(schema_path)
|
||||||
|
@@ -273,7 +273,7 @@ class TestErrorTree(unittest.TestCase):
|
|||||||
self.assertIsInstance(tree["foo"], exceptions.ErrorTree)
|
self.assertIsInstance(tree["foo"], exceptions.ErrorTree)
|
||||||
|
|
||||||
|
|
||||||
class TestErrorReprStr(unittest.TestCase):
|
class TestErrorInitReprStr(unittest.TestCase):
|
||||||
def make_error(self, **kwargs):
|
def make_error(self, **kwargs):
|
||||||
defaults = dict(
|
defaults = dict(
|
||||||
message=u"hello",
|
message=u"hello",
|
||||||
@@ -295,6 +295,10 @@ class TestErrorReprStr(unittest.TestCase):
|
|||||||
self.assertEqual(message_line, error.message)
|
self.assertEqual(message_line, error.message)
|
||||||
self.assertEqual(rest, expected)
|
self.assertEqual(rest, expected)
|
||||||
|
|
||||||
|
def test_it_calls_super_and_sets_args(self):
|
||||||
|
error = self.make_error()
|
||||||
|
self.assertGreater(len(error.args), 1)
|
||||||
|
|
||||||
def test_repr(self):
|
def test_repr(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
repr(exceptions.ValidationError(message="Hello!")),
|
repr(exceptions.ValidationError(message="Hello!")),
|
||||||
|
Reference in New Issue
Block a user