Add a simple test and all of the args.
This commit is contained in:
parent
ff426eb870
commit
1610e2802d
|
@ -27,10 +27,18 @@ class _Error(Exception):
|
|||
schema_path=(),
|
||||
parent=None,
|
||||
):
|
||||
# Calling __init__ is important, because otherwise __reduce__ will
|
||||
# return empty args tuple on Py2.7 and unpickling will fail because
|
||||
# init requires at least one argument.
|
||||
super(_Error, self).__init__(message)
|
||||
super(_Error, self).__init__(
|
||||
message,
|
||||
validator,
|
||||
path,
|
||||
cause,
|
||||
context,
|
||||
validator_value,
|
||||
instance,
|
||||
schema,
|
||||
schema_path,
|
||||
parent,
|
||||
)
|
||||
self.message = message
|
||||
self.path = self.relative_path = deque(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)
|
||||
|
||||
|
||||
class TestErrorReprStr(unittest.TestCase):
|
||||
class TestErrorInitReprStr(unittest.TestCase):
|
||||
def make_error(self, **kwargs):
|
||||
defaults = dict(
|
||||
message=u"hello",
|
||||
|
@ -295,6 +295,10 @@ class TestErrorReprStr(unittest.TestCase):
|
|||
self.assertEqual(message_line, error.message)
|
||||
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):
|
||||
self.assertEqual(
|
||||
repr(exceptions.ValidationError(message="Hello!")),
|
||||
|
|
Loading…
Reference in New Issue