MCPcopy
hub / github.com/fastapi/fastapi / test_encode_class

Function test_encode_class

tests/test_jsonable_encoder.py:99–109  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

97
98
99def test_encode_class():
100 person = Person(name="Foo")
101 pet = Pet(owner=person, name="Firulais")
102 assert jsonable_encoder(pet) == {"name": "Firulais", "owner": {"name": "Foo"}}
103 assert jsonable_encoder(pet, include={"name"}) == {"name": "Firulais"}
104 assert jsonable_encoder(pet, exclude={"owner"}) == {"name": "Firulais"}
105 assert jsonable_encoder(pet, include={}) == {}
106 assert jsonable_encoder(pet, exclude={}) == {
107 "name": "Firulais",
108 "owner": {"name": "Foo"},
109 }
110
111
112def test_encode_dictable():

Callers

nothing calls this directly

Calls 3

jsonable_encoderFunction · 0.90
PetClass · 0.85
PersonClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…