@@ -3,7 +3,7 @@ use std::collections::HashMap;
33use pyo3:: {
44 exceptions:: { PyIndexError , PyKeyError } ,
55 prelude:: * ,
6- types:: { PyDict , PyList , PyMapping , PySequence } ,
6+ types:: { PyDict , PyMapping , PySequence , PyTuple } ,
77} ;
88use pythonize:: {
99 depythonize, pythonize_custom, PythonizeListType , PythonizeMappingType , PythonizeTypes ,
@@ -134,7 +134,7 @@ struct PythonizeCustomDict;
134134impl PythonizeTypes for PythonizeCustomDict {
135135 type Map = CustomDict ;
136136 type NamedMap = PythonizeUnnamedMappingWrapper < CustomDict > ;
137- type List = PyList ;
137+ type List = PyTuple ;
138138}
139139
140140#[ test]
@@ -151,6 +151,19 @@ fn test_custom_dict() {
151151 } )
152152}
153153
154+ #[ test]
155+ fn test_tuple ( ) {
156+ Python :: with_gil ( |py| {
157+ PyMapping :: register :: < CustomDict > ( py) . unwrap ( ) ;
158+ let serialized =
159+ pythonize_custom :: < PythonizeCustomDict , _ > ( py, & json ! ( [ 1 , 2 , 3 , 4 ] ) ) . unwrap ( ) ;
160+ assert ! ( serialized. is_instance_of:: <PyTuple >( ) ) ;
161+
162+ let deserialized: Value = depythonize ( & serialized) . unwrap ( ) ;
163+ assert_eq ! ( deserialized, json!( [ 1 , 2 , 3 , 4 ] ) ) ;
164+ } )
165+ }
166+
154167#[ test]
155168fn test_pythonizer_can_be_created ( ) {
156169 // https://github.com/davidhewitt/pythonize/pull/56
0 commit comments