@@ -418,7 +418,7 @@ def test_maxItems(self):
418
418
message = self .message_for (instance = [1 , 2 , 3 ], schema = {"maxItems" : 2 })
419
419
self .assertEqual (message , "[1, 2, 3] is too long" )
420
420
421
- def test_prefixItems (self ):
421
+ def test_prefixItems_with_items (self ):
422
422
message = self .message_for (
423
423
instance = [1 , 2 , "foo" , 5 ],
424
424
schema = {"items" : False , "prefixItems" : [{}, {}]},
@@ -1114,6 +1114,55 @@ def test_ref(self):
1114
1114
),
1115
1115
)
1116
1116
1117
+ def test_prefixItems (self ):
1118
+ schema = {"prefixItems" : [{"type" : "string" }, {}, {}, {"maximum" : 3 }]}
1119
+ validator = validators .Draft202012Validator (schema )
1120
+ type_error , min_error = validator .iter_errors ([1 , 2 , "foo" , 5 ])
1121
+ self .assertEqual (
1122
+ (
1123
+ type_error .message ,
1124
+ type_error .validator ,
1125
+ type_error .validator_value ,
1126
+ type_error .instance ,
1127
+ type_error .absolute_path ,
1128
+ type_error .schema ,
1129
+ type_error .schema_path ,
1130
+ type_error .json_path ,
1131
+ ),
1132
+ (
1133
+ "1 is not of type 'string'" ,
1134
+ "type" ,
1135
+ "string" ,
1136
+ 1 ,
1137
+ deque ([]),
1138
+ {"type" : "string" },
1139
+ deque (["prefixItems" , 0 , "type" ]),
1140
+ "$" ,
1141
+ ),
1142
+ )
1143
+ self .assertEqual (
1144
+ (
1145
+ min_error .message ,
1146
+ min_error .validator ,
1147
+ min_error .validator_value ,
1148
+ min_error .instance ,
1149
+ min_error .absolute_path ,
1150
+ min_error .schema ,
1151
+ min_error .schema_path ,
1152
+ min_error .json_path ,
1153
+ ),
1154
+ (
1155
+ "5 is greater than the maximum of 3" ,
1156
+ "maximum" ,
1157
+ 3 ,
1158
+ 5 ,
1159
+ deque ([]),
1160
+ {"maximum" : 3 },
1161
+ deque (["prefixItems" , 3 , "maximum" ]),
1162
+ "$" ,
1163
+ ),
1164
+ )
1165
+
1117
1166
1118
1167
class MetaSchemaTestsMixin (object ):
1119
1168
# TODO: These all belong upstream
0 commit comments