Skip to content

Commit a51f2e9

Browse files
committed
fix tests, ser to string for json mode
1 parent 06e37fd commit a51f2e9

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/serializers/infer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ pub(crate) fn infer_to_python_known(
232232
}
233233
ObType::Complex => {
234234
let v = value.downcast::<PyComplex>()?;
235-
v.into_py(py)
235+
let complex_str = type_serializers::complex::complex_to_str(v);
236+
complex_str.into_py(py)
236237
}
237238
ObType::Path => value.str()?.into_py(py),
238239
ObType::Pattern => value.getattr(intern!(py, "pattern"))?.into_py(py),

tests/serializers/test_complex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ def test_complex_json(value, expected):
4242
def test_complex_inference() -> None:
4343
s = SchemaSerializer(core_schema.any_schema())
4444
assert s.to_python(1 + 2j) == 1 + 2j
45-
assert s.to_json(1 + 2j) == '1+2j'
45+
assert s.to_json(1 + 2j) == b'"1+2j"'

0 commit comments

Comments
 (0)