Skip to content

Commit 2595552

Browse files
authored
Merge pull request #71 from davidhewitt/coverage
add some more coverage
2 parents 1b5c844 + 96f52ad commit 2595552

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/de.rs

+35
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)