Skip to content

Commit cc80ddf

Browse files
committed
refactor test
1 parent e49d8f9 commit cc80ddf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/serializers/test_model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def computed_field_x(self) -> int:
575575
return self.x + 200
576576

577577
def ser_func(self, v: Any, info: core_schema.FieldSerializationInfo) -> str:
578-
return str(v * 2)
578+
return info.field_name + '_' + str(v * 2)
579579

580580
field_str_with_field_serializer = core_schema.str_schema(
581581
serialization=core_schema.plain_serializer_function_ser_schema(
@@ -597,8 +597,8 @@ def ser_func(self, v: Any, info: core_schema.FieldSerializationInfo) -> str:
597597
),
598598
)
599599
)
600-
assert json.loads(s.to_json(Model(x=1000))) == {'x': '2000', 'computed_field_x': '2400'}
601-
assert s.to_python(Model(x=2000)) == {'x': '4000', 'computed_field_x': '4400'}
600+
assert json.loads(s.to_json(Model(x=1000))) == {'x': 'x_2000', 'computed_field_x': 'computed_field_x_2400'}
601+
assert s.to_python(Model(x=2000)) == {'x': 'x_4000', 'computed_field_x': 'computed_field_x_4400'}
602602

603603

604604
def test_function_wrap_field_serializer_to_json():

0 commit comments

Comments
 (0)