File tree Expand file tree Collapse file tree 1 file changed +3
-13
lines changed
Expand file tree Collapse file tree 1 file changed +3
-13
lines changed Original file line number Diff line number Diff line change @@ -48,22 +48,12 @@ def test_populate_by_name_enabled(self):
4848 )
4949 def test_camel_case_alias_generation (self , case : CamelModelTestCase ):
5050 """Test that snake_case fields are aliased to camelCase."""
51+ from pydantic import create_model
5152
52- class TestModel (CamelModel ):
53- pass
54-
55- TestModel .model_rebuild ()
56-
57- local_ns = {}
58- exec (
59- f"""class DynamicModel(CamelModel):
60- { case .field_name } : str = "test"
61- """ ,
62- {"CamelModel" : CamelModel },
63- local_ns ,
53+ DynamicModel = create_model (
54+ "DynamicModel" , __base__ = CamelModel , ** {case .field_name : (str , "test" )}
6455 )
6556
66- DynamicModel = local_ns ["DynamicModel" ]
6757 field_info = DynamicModel .model_fields [case .field_name ]
6858 assert field_info .alias == case .expected_alias
6959
You can’t perform that action at this time.
0 commit comments