File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -793,4 +793,39 @@ mod test {
793793 let _: i128 = depythonize ( & i128:: MIN . into_py ( py) . into_bound ( py) ) . unwrap ( ) ;
794794 } ) ;
795795 }
796+
797+ #[ test]
798+ fn test_deserialize_bytes ( ) {
799+ Python :: with_gil ( |py| {
800+ let obj = PyBytes :: new_bound ( py, "hello" . as_bytes ( ) ) ;
801+ let actual: Vec < u8 > = depythonize ( & obj) . unwrap ( ) ;
802+ assert_eq ! ( actual, b"hello" ) ;
803+ } )
804+ }
805+
806+ #[ test]
807+ fn test_char ( ) {
808+ let expected = 'a' ;
809+ let expected_json = json ! ( "a" ) ;
810+ let code = "'a'" ;
811+ test_de ( code, & expected, & expected_json) ;
812+ }
813+
814+ #[ test]
815+ fn test_unknown_type ( ) {
816+ Python :: with_gil ( |py| {
817+ let obj = py
818+ . import_bound ( "decimal" )
819+ . unwrap ( )
820+ . getattr ( "Decimal" )
821+ . unwrap ( )
822+ . call0 ( )
823+ . unwrap ( ) ;
824+ let err = depythonize :: < serde_json:: Value > ( & obj) . unwrap_err ( ) ;
825+ assert ! ( matches!(
826+ * err. inner,
827+ ErrorImpl :: UnsupportedType ( name) if name == "Decimal"
828+ ) ) ;
829+ } ) ;
830+ }
796831}
You can’t perform that action at this time.
0 commit comments