Skip to content

Commit 124b81a

Browse files
author
Itamar Turner-Trauring
committed
Address review comments.
1 parent 822c75f commit 124b81a

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

jsonschema/_validators.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ def additionalProperties(validator, aP, instance, schema):
3030
yield error
3131
elif not aP and extras:
3232
if "patternProperties" in schema:
33-
patterns = sorted(schema["patternProperties"].keys())
33+
patterns = sorted(schema["patternProperties"])
3434
if len(extras) == 1:
3535
verb = "does"
3636
else:
3737
verb = "do"
38-
error = "%s %s not match any of the regexs: %s" % (
39-
", ".join(map(repr, sorted(extras))), verb, ", ".join(patterns))
38+
error = "%s %s not match any of the regexes: %s" % (
39+
", ".join(map(repr, sorted(extras))),
40+
verb,
41+
", ".join(map(repr, patterns)),
42+
)
4043
yield ValidationError(error)
4144
else:
4245
error = "Additional properties are not allowed (%s %s unexpected)"

jsonschema/tests/test_validators.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,21 +195,25 @@ def test_additionalProperties_false_patternProperties(self):
195195
schema = {u"type": u"object",
196196
u"additionalProperties": False,
197197
u"patternProperties": {
198-
u"$abc^": {u"type": u"string"},
199-
u"$def^": {u"type": u"string"}
198+
u"^abc$": {u"type": u"string"},
199+
u"^def$": {u"type": u"string"}
200200
}}
201201
message = self.message_for({u"zebra": 123}, schema,
202202
cls=Draft4Validator)
203203
self.assertEqual(
204204
message,
205-
"{} does not match any of the regexs: $abc^, $def^".format(
206-
repr(u"zebra")))
205+
"{} does not match any of the regexes: {}, {}".format(
206+
repr(u"zebra"), repr(u"^abc$"), repr(u"^def$"),
207+
),
208+
)
207209
message = self.message_for({u"zebra": 123, u"fish": 456}, schema,
208210
cls=Draft4Validator)
209211
self.assertEqual(
210212
message,
211-
"{}, {} do not match any of the regexs: $abc^, $def^".format(
212-
repr(u"fish"), repr(u"zebra")))
213+
"{}, {} do not match any of the regexes: {}, {}".format(
214+
repr(u"fish"), repr(u"zebra"), repr(u"^abc$"), repr(u"^def$")
215+
),
216+
)
213217

214218

215219
class TestValidationErrorDetails(unittest.TestCase):

0 commit comments

Comments
 (0)