diff --git a/tests/test_frompyobject.rs b/tests/test_frompyobject.rs index 57ecf1d6..152466cc 100644 --- a/tests/test_frompyobject.rs +++ b/tests/test_frompyobject.rs @@ -501,3 +501,23 @@ fn test_from_py_with_tuple_struct() { assert_eq!(zap.1, 3usize); }); } + +#[derive(Debug, FromPyObject, PartialEq)] +pub enum ZapEnum { + Zip(#[pyo3(from_py_with = "PyAny::len")] usize), + Zap(String, #[pyo3(from_py_with = "PyAny::len")] usize), +} + +#[test] +fn test_from_py_with_enum() { + Python::with_gil(|py| { + let py_zap = py + .eval(r#"("whatever", [1, 2, 3])"#, None, None) + .expect("failed to create dict"); + + let zap = ZapEnum::extract(py_zap).unwrap(); + let expected_zap = ZapEnum::Zap(String::from("whatever"), 3usize); + + assert_eq!(zap, expected_zap); + }); +}