Skip to content

Commit 9632422

Browse files
committed
Fix the contains error message.
1 parent c671b17 commit 9632422

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

jsonschema/_validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def contains(validator, contains, instance, schema):
127127

128128
if not any(validator.is_valid(element, contains) for element in instance):
129129
yield ValidationError(
130-
"XXX"
130+
"None of %r are valid under the given schema" % (instance,)
131131
)
132132

133133

jsonschema/tests/test_validators.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,18 @@ def test_const(self):
368368
)
369369
self.assertIn("12 was expected", message)
370370

371+
def test_contains(self):
372+
schema = {u"contains": {u"const": 12}}
373+
message = self.message_for(
374+
instance=[2, {}, []],
375+
schema=schema,
376+
cls=validators.Draft6Validator,
377+
)
378+
self.assertIn(
379+
"None of [2, {}, []] are valid under the given schema",
380+
message,
381+
)
382+
371383
def test_invalid_format_default_message(self):
372384
checker = FormatChecker(formats=())
373385
check_fn = mock.Mock(return_value=False)

0 commit comments

Comments
 (0)