MCPcopy
hub / github.com/pydantic/pydantic / test_complex_json

Function test_complex_json

pydantic-core/tests/serializers/test_complex.py:25–42  ·  view source on GitHub ↗
(value, expected)

Source from the content-addressed store, hash-verified

23 ],
24)
25def test_complex_json(value, expected):
26 v = SchemaSerializer(core_schema.complex_schema())
27 c = v.to_python(value)
28 c_json = v.to_python(value, mode='json')
29 json_str = v.to_json(value).decode()
30
31 assert c_json == expected
32 assert json_str == f'"{expected}"'
33
34 if math.isnan(value.imag):
35 assert math.isnan(c.imag)
36 else:
37 assert c.imag == value.imag
38
39 if math.isnan(value.real):
40 assert math.isnan(c.real)
41 else:
42 assert c.real == value.real
43
44
45def test_complex_inference() -> None:

Callers

nothing calls this directly

Calls 2

complex_schemaMethod · 0.80
decodeMethod · 0.45

Tested by

no test coverage detected