@@ -419,15 +419,13 @@ def maximum(self, expect, eM, instance):
419
419
("exact" , "valid" , [1 ]),
420
420
("longer" , "valid" , [1 , 2 ]),
421
421
("too_short" , "invalid" , []),
422
- ("ignores_strings" , "valid" , "a" ),
423
422
)(validation_test (minItems = 1 ))
424
423
425
424
maxItems = parametrized (
426
425
("exact" , "valid" , [1 , 2 ]),
427
426
("shorter" , "valid" , [1 ]),
428
427
("empty" , "valid" , []),
429
428
("too_long" , "invalid" , [1 , 2 , 3 ]),
430
- ("ignores_strings" , "valid" , "aaaa" ),
431
429
)(validation_test (maxItems = 2 ))
432
430
433
431
uniqueItems = parametrized (
@@ -450,19 +448,16 @@ def maximum(self, expect, eM, instance):
450
448
pattern = parametrized (
451
449
("match" , "valid" , "aaa" ),
452
450
("mismatch" , "invalid" , "ab" ),
453
- ("ignores_other_stuff" , "valid" , True ),
454
451
)(validation_test (pattern = "^a*$" ))
455
452
456
453
minLength = parametrized (
457
454
("" , "valid" , "foo" ),
458
455
("too_short" , "invalid" , "f" ),
459
- ("ignores_arrays" , "valid" , [1 ]),
460
456
)(validation_test (minLength = 2 ))
461
457
462
458
maxLength = parametrized (
463
459
("" , "valid" , "f" ),
464
460
("too_long" , "invalid" , "foo" ),
465
- ("ignores_arrays" , "valid" , [1 , 2 , 3 ]),
466
461
)(validation_test (maxLength = 2 ))
467
462
468
463
@parametrized (
@@ -824,24 +819,45 @@ def test_tree(self):
824
819
825
820
826
821
class TestIgnorePropertiesForIrrelevantTypes (unittest .TestCase ):
827
- def test_minimum (self ):
822
+ def test_minimum_ignores_nonnumbers (self ):
828
823
validate ("x" , {"type" : ["string" , "number" ], "minimum" : 10 })
829
824
830
- def test_maximum (self ):
825
+ def test_maximum_ignores_nonnumbers (self ):
831
826
validate ("x" , {"type" : ["string" , "number" ], "maximum" : 10 })
832
827
833
- def test_properties (self ):
828
+ def test_properties_ignores_nonobjects (self ):
834
829
validate (1 , {"type" : ["integer" , "object" ], "properties" : {"x" : {}}})
835
830
836
- def test_items (self ):
831
+ def test_additionalProperties_ignores_nonobjects (self ):
832
+ validate (None , {"additionalProperties" : False })
833
+
834
+ def test_minLength_ignores_nonstrings (self ):
835
+ validate ([1 ], {"minLength" : 3 })
836
+
837
+ def test_maxLength_ignores_nonstrings (self ):
838
+ validate ([1 , 2 , 3 ], {"minLength" : 2 })
839
+
840
+ def test_pattern_ignores_non_strings (self ):
841
+ validate (True , {"pattern" : "^a*$" })
842
+
843
+ def test_items_ignores_nonarrays (self ):
837
844
validate (
838
845
1 , {"type" : ["integer" , "array" ], "items" : {"type" : "string" }}
839
846
)
840
847
841
- def test_divisibleBy (self ):
848
+ def test_minItems_ignores_nonarrays (self ):
849
+ validate ("x" , {"minItems" : 3 })
850
+
851
+ def test_maxItems_ignores_nonarrays (self ):
852
+ validate ("xxxx" , {"maxItems" : 3 })
853
+
854
+ def test_additionalItems_ignores_nonarrays (self ):
855
+ validate (None , {"additionalItems" : False })
856
+
857
+ def test_divisibleBy_ignores_nonnumbers (self ):
842
858
validate ("x" , {"type" : ["integer" , "string" ], "divisibleBy" : 10 })
843
859
844
- def test_dependencies (self ):
860
+ def test_dependencies_ignores_nonobjects (self ):
845
861
validate ("foo" , {"dependencies" : {"foo" : "bar" }})
846
862
847
863
0 commit comments