@@ -240,6 +240,30 @@ def test_basic_type_formats(
240
240
241
241
assert result == unmarshalled
242
242
243
+ @pytest .mark .parametrize (
244
+ "type,format,value" ,
245
+ [
246
+ ("string" , "float" , "test" ),
247
+ ("string" , "double" , "test" ),
248
+ ("number" , "date" , 3 ),
249
+ ("number" , "date-time" , 3 ),
250
+ ("number" , "uuid" , 3 ),
251
+ ],
252
+ )
253
+ def test_basic_type_formats_ignored (
254
+ self , unmarshallers_factory , type , format , value
255
+ ):
256
+ schema = {
257
+ "type" : type ,
258
+ "format" : format ,
259
+ }
260
+ spec = Spec .from_dict (schema , validator = None )
261
+ unmarshaller = unmarshallers_factory .create (spec )
262
+
263
+ result = unmarshaller .unmarshal (value )
264
+
265
+ assert result == value
266
+
243
267
@pytest .mark .parametrize (
244
268
"type,format,value" ,
245
269
[
@@ -374,23 +398,17 @@ def test_string_uuid_invalid(self, unmarshallers_factory):
374
398
assert len (exc_info .value .schema_errors ) == 1
375
399
assert f"is not a 'uuid'" in exc_info .value .schema_errors [0 ].message
376
400
377
- @pytest .mark .xfail (
378
- reason = (
379
- "Formats raise error for other types. "
380
- "See https://github.com./python-openapi/openapi-schema-validator/issues/66"
381
- )
382
- )
383
401
@pytest .mark .parametrize (
384
402
"type,format,value,expected" ,
385
403
[
386
404
("string" , "float" , "test" , "test" ),
387
405
("string" , "double" , "test" , "test" ),
388
- ("string " , "byte" , "test" , "test" ),
389
- ("integer" , "date" , "10" , 10 ),
390
- ("integer" , "date-time" , "10" , 10 ),
406
+ ("integer " , "byte" , 10 , 10 ),
407
+ ("integer" , "date" , 10 , 10 ),
408
+ ("integer" , "date-time" , 10 , 10 ),
391
409
("string" , "int32" , "test" , "test" ),
392
410
("string" , "int64" , "test" , "test" ),
393
- ("integer" , "password" , "10" , 10 ),
411
+ ("integer" , "password" , 10 , 10 ),
394
412
],
395
413
)
396
414
def test_formats_ignored (
@@ -1728,7 +1746,8 @@ def test_basic_type_oas30_formats_invalid(
1728
1746
reason = (
1729
1747
"OAS 3.0 string type checker allows byte. "
1730
1748
"See https://github.com./python-openapi/openapi-schema-validator/issues/64"
1731
- )
1749
+ ),
1750
+ strict = True ,
1732
1751
)
1733
1752
def test_string_format_binary_invalid (self , unmarshallers_factory ):
1734
1753
schema = {
@@ -1748,7 +1767,8 @@ def test_string_format_binary_invalid(self, unmarshallers_factory):
1748
1767
reason = (
1749
1768
"Rraises TypeError not SchemaError. "
1750
1769
"See ttps://github.com./python-openapi/openapi-schema-validator/issues/65"
1751
- )
1770
+ ),
1771
+ strict = True ,
1752
1772
)
1753
1773
@pytest .mark .parametrize (
1754
1774
"types,value" ,
@@ -1928,7 +1948,8 @@ def unmarshallers_factory(self):
1928
1948
reason = (
1929
1949
"OpenAPI 3.1 schema validator uses OpenAPI 3.0 format checker."
1930
1950
"See https://github.com./python-openapi/openapi-core/issues/506"
1931
- )
1951
+ ),
1952
+ strict = True ,
1932
1953
)
1933
1954
@pytest .mark .parametrize (
1934
1955
"type,format" ,
0 commit comments