diff options
author | Julian Berman <Julian@GrayVines.com> | 2021-08-24 10:21:41 +0100 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2021-08-24 10:21:41 +0100 |
commit | 53694e776adfc0b3f8b49101d1477f091c1dc0d9 (patch) | |
tree | 5a6590b272280aad273a6398a8b70ee1609e988a /jsonschema/tests | |
parent | 60d689ca25012cc223166407f73348c86d13a1b4 (diff) | |
download | jsonschema-53694e776adfc0b3f8b49101d1477f091c1dc0d9.tar.gz |
Fix items' instance path as well.
Diffstat (limited to 'jsonschema/tests')
-rw-r--r-- | jsonschema/tests/test_validators.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/jsonschema/tests/test_validators.py b/jsonschema/tests/test_validators.py index 7f5f387..026ee85 100644 --- a/jsonschema/tests/test_validators.py +++ b/jsonschema/tests/test_validators.py @@ -1163,6 +1163,58 @@ class TestValidationErrorDetails(TestCase): ), ) + def test_prefixItems_with_items(self): + schema = { + "items": {"type": "string"}, + "prefixItems": [{}], + } + validator = validators.Draft202012Validator(schema) + e1, e2 = validator.iter_errors(["foo", 2, "bar", 4, "baz"]) + self.assertEqual( + ( + e1.message, + e1.validator, + e1.validator_value, + e1.instance, + e1.absolute_path, + e1.schema, + e1.schema_path, + e1.json_path, + ), + ( + "2 is not of type 'string'", + "type", + "string", + 2, + deque([1]), + {"type": "string"}, + deque(["items", "type"]), + "$[1]", + ), + ) + self.assertEqual( + ( + e2.message, + e2.validator, + e2.validator_value, + e2.instance, + e2.absolute_path, + e2.schema, + e2.schema_path, + e2.json_path, + ), + ( + "4 is not of type 'string'", + "type", + "string", + 4, + deque([3]), + {"type": "string"}, + deque(["items", "type"]), + "$[3]", + ), + ) + class MetaSchemaTestsMixin(object): # TODO: These all belong upstream |