MCPcopy
hub / github.com/fastapi/fastapi / test_encode_dictable

Function test_encode_dictable

tests/test_jsonable_encoder.py:112–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

110
111
112def test_encode_dictable():
113 person = DictablePerson(name="Foo")
114 pet = DictablePet(owner=person, name="Firulais")
115 assert jsonable_encoder(pet) == {"name": "Firulais", "owner": {"name": "Foo"}}
116 assert jsonable_encoder(pet, include={"name"}) == {"name": "Firulais"}
117 assert jsonable_encoder(pet, exclude={"owner"}) == {"name": "Firulais"}
118 assert jsonable_encoder(pet, include={}) == {}
119 assert jsonable_encoder(pet, exclude={}) == {
120 "name": "Firulais",
121 "owner": {"name": "Foo"},
122 }
123
124
125def test_encode_dataclass():

Callers

nothing calls this directly

Calls 3

jsonable_encoderFunction · 0.90
DictablePersonClass · 0.85
DictablePetClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…