@@ -258,6 +258,21 @@ def additionalProperties(self, aP):
258258 def test_additionalProperties_ignores_nonobjects (self ):
259259 validate (None , {"additionalProperties" : False })
260260
261+ @parametrized (
262+ ("single_extra" , {"foo" : 2 }, ["('foo' was unexpected)" ]),
263+ ("multiple_extras" ,
264+ dict .fromkeys (["foo" , "bar" , "quux" ]),
265+ ["'bar'" , "'foo'" , "'quux'" , "were unexpected)" ],
266+ ),
267+ )
268+ def additionalProperties_errorMessage (self , instance , errs ):
269+ schema = {"additionalProperties" : False }
270+
271+ with self .assertRaises (ValidationError ) as error :
272+ validate (instance , schema )
273+
274+ self .assertTrue (all (err in error .exception .message for err in errs ))
275+
261276 items = parametrized (
262277 ("" , "valid" , [1 , 2 , 3 ]),
263278 ("wrong_type" , "invalid" , [1 , u"x" ]),
@@ -293,6 +308,16 @@ def test_additionalItems_allowed_by_default(self):
293308 def test_additionalItems_ignores_nonarrays (self ):
294309 validate (None , {"additionalItems" : False })
295310
311+ @parametrized (
312+ ("single_extra" , [2 ], "(2 was unexpected)" ),
313+ ("multiple_extras" , [1 , 2 , 3 ], "(1, 2, 3 were unexpected)" ),
314+ )
315+ def additionalItems_errorMessage (self , instance , err ):
316+ schema = {"additionalItems" : False }
317+ self .assertRaisesRegexp (
318+ ValidationError , err , validate , instance , schema
319+ )
320+
296321 @parametrized (
297322 ("false_by_default" , "valid" , {}, {}),
298323 ("false_explicit" , "valid" , {u"required" : False }, {}),
0 commit comments