Skip to content

Commit 1610e28

Browse files
committed
Add a simple test and all of the args.
1 parent ff426eb commit 1610e28

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

jsonschema/exceptions.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,18 @@ def __init__(
2727
schema_path=(),
2828
parent=None,
2929
):
30-
# Calling __init__ is important, because otherwise __reduce__ will
31-
# return empty args tuple on Py2.7 and unpickling will fail because
32-
# init requires at least one argument.
33-
super(_Error, self).__init__(message)
30+
super(_Error, self).__init__(
31+
message,
32+
validator,
33+
path,
34+
cause,
35+
context,
36+
validator_value,
37+
instance,
38+
schema,
39+
schema_path,
40+
parent,
41+
)
3442
self.message = message
3543
self.path = self.relative_path = deque(path)
3644
self.schema_path = self.relative_schema_path = deque(schema_path)

jsonschema/tests/test_exceptions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def test_if_its_in_the_tree_anyhow_it_does_not_raise_an_error(self):
273273
self.assertIsInstance(tree["foo"], exceptions.ErrorTree)
274274

275275

276-
class TestErrorReprStr(unittest.TestCase):
276+
class TestErrorInitReprStr(unittest.TestCase):
277277
def make_error(self, **kwargs):
278278
defaults = dict(
279279
message=u"hello",
@@ -295,6 +295,10 @@ def assertShows(self, expected, **kwargs):
295295
self.assertEqual(message_line, error.message)
296296
self.assertEqual(rest, expected)
297297

298+
def test_it_calls_super_and_sets_args(self):
299+
error = self.make_error()
300+
self.assertGreater(len(error.args), 1)
301+
298302
def test_repr(self):
299303
self.assertEqual(
300304
repr(exceptions.ValidationError(message="Hello!")),

0 commit comments

Comments
 (0)