@@ -835,6 +835,34 @@ def test_additional_properties_list(self, unmarshaller_factory):
835835 "user_ids" : [1 , 2 , 3 , 4 ],
836836 }
837837
838+ @pytest .mark .xfail (message = "None and NOTSET should be distinguished" )
839+ def test_null_not_supported (self , unmarshaller_factory ):
840+ schema = {"type" : "null" }
841+ spec = Spec .from_dict (schema )
842+
843+ with pytest .raises (InvalidSchemaValue ):
844+ unmarshaller_factory (spec )(None )
845+
846+ @pytest .mark .parametrize (
847+ "types,value" ,
848+ [
849+ (["string" , "null" ], "string" ),
850+ (["number" , "null" ], 2 ),
851+ (["number" , "null" ], 3.14 ),
852+ (["boolean" , "null" ], True ),
853+ (["array" , "null" ], [1 , 2 ]),
854+ (["object" , "null" ], {}),
855+ ],
856+ )
857+ def test_nultiple_types_not_supported (
858+ self , unmarshaller_factory , types , value
859+ ):
860+ schema = {"type" : types }
861+ spec = Spec .from_dict (schema )
862+
863+ with pytest .raises (TypeError ):
864+ unmarshaller_factory (spec )(value )
865+
838866
839867class TestOAS31SchemaUnmarshallerCall :
840868 @pytest .fixture
@@ -856,3 +884,40 @@ def test_null_invalid(self, unmarshaller_factory, value):
856884
857885 with pytest .raises (InvalidSchemaValue ):
858886 unmarshaller_factory (spec )(value )
887+
888+ @pytest .mark .parametrize (
889+ "types,value" ,
890+ [
891+ (["string" , "null" ], "string" ),
892+ (["number" , "null" ], 2 ),
893+ (["number" , "null" ], 3.14 ),
894+ (["boolean" , "null" ], True ),
895+ (["array" , "null" ], [1 , 2 ]),
896+ (["object" , "null" ], {}),
897+ ],
898+ )
899+ def test_nultiple_types (self , unmarshaller_factory , types , value ):
900+ schema = {"type" : types }
901+ spec = Spec .from_dict (schema )
902+
903+ result = unmarshaller_factory (spec )(value )
904+
905+ assert result == value
906+
907+ @pytest .mark .parametrize (
908+ "types,value" ,
909+ [
910+ (["string" , "null" ], 2 ),
911+ (["number" , "null" ], "string" ),
912+ (["number" , "null" ], True ),
913+ (["boolean" , "null" ], 3.14 ),
914+ (["array" , "null" ], {}),
915+ (["object" , "null" ], [1 , 2 ]),
916+ ],
917+ )
918+ def test_nultiple_types_invalid (self , unmarshaller_factory , types , value ):
919+ schema = {"type" : types }
920+ spec = Spec .from_dict (schema )
921+
922+ with pytest .raises (InvalidSchemaValue ):
923+ unmarshaller_factory (spec )(value )
0 commit comments