Fixes Behavior of Pydantic None Type and Adds More Tests

This commit is contained in:
2025-08-18 23:33:16 -03:00
parent e9d61a1268
commit 00d88388f8
3 changed files with 28 additions and 29 deletions

View File

@@ -657,3 +657,23 @@ class TestSchemaConverter(TestCase):
with self.assertRaises(ValueError):
Model(name="Canada")
def test_null_type_parser(self):
schema = {
"title": "Test",
"type": "object",
"properties": {
"a_thing": {"type": "null"},
},
}
Model = SchemaConverter.build(schema)
obj = Model()
self.assertIsNone(obj.a_thing)
obj = Model(a_thing=None)
self.assertIsNone(obj.a_thing)
with self.assertRaises(ValueError):
Model(a_thing="not none")