Skip to content

Commit 85cb502

Browse files
adding additional test cases for that sweet total coverage check
1 parent cae0633 commit 85cb502

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tests/serializers/test_typed_dict.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,14 @@ def __get_pydantic_core_schema__(*args):
187187
def __eq__(self, other):
188188
raise NotImplementedError("Can't be compared!")
189189

190+
class NeqComparable(Incomparable):
191+
def __eq__(self, other):
192+
return False
193+
194+
class EqComparable(Incomparable):
195+
def __eq__(self, other):
196+
return True
197+
190198
v = SchemaSerializer(
191199
core_schema.typed_dict_schema(
192200
{
@@ -196,9 +204,13 @@ def __eq__(self, other):
196204
}
197205
)
198206
)
199-
instance = Incomparable()
200-
assert v.to_python({'foo': instance}, exclude_defaults=True)['foo'] == [1, 2, 3]
201-
assert v.to_json({'foo': instance}, exclude_defaults=True) == b'{"foo":[1,2,3]}'
207+
208+
assert v.to_python({'foo': Incomparable()}, exclude_defaults=True)['foo'] == [1, 2, 3]
209+
assert v.to_json({'foo': Incomparable()}, exclude_defaults=True) == b'{"foo":[1,2,3]}'
210+
assert v.to_python({'foo': NeqComparable()}, exclude_defaults=True)['foo'] == [1, 2, 3]
211+
assert v.to_json({'foo': NeqComparable()}, exclude_defaults=True) == b'{"foo":[1,2,3]}'
212+
assert v.to_python({'foo': EqComparable()}, exclude_defaults=True) == {}
213+
assert v.to_json({'foo': EqComparable()}, exclude_defaults=True) == b'{}'
202214

203215

204216
def test_function_plain_field_serializer_to_python():

0 commit comments

Comments
 (0)