diff --git a/tests/test_frompyobject.rs b/tests/test_frompyobject.rs index 064d6d1a587..bb8112204f2 100644 --- a/tests/test_frompyobject.rs +++ b/tests/test_frompyobject.rs @@ -300,17 +300,13 @@ fn test_err_rename() { ); } -fn to_string(obj: &PyAny) -> PyResult { - Ok(obj.str()?.to_str()?.to_string()) -} - #[derive(Debug, FromPyObject)] pub struct Zap { #[pyo3(item)] name: String, - #[pyo3(from_py_with = "to_string", item("my_object"))] - some_object: String, + #[pyo3(from_py_with = "PyAny::len", item("my_object"))] + some_object_length: usize, } #[test] @@ -327,6 +323,6 @@ fn test_from_py_with() { let zap = Zap::extract(py_zap).unwrap(); assert_eq!(zap.name, "whatever"); - assert_eq!(zap.some_object, "[1, 2, 3]"); + assert_eq!(zap.some_object_length, 3usize); }); }