Skip to content

Commit 4d5a48e

Browse files
author
Datata1
committed
test: fix ci
1 parent b3946ec commit 4d5a48e

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

tests/core/test_base.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)