Skip to content

Commit

Permalink
Merge pull request #71 from davidhewitt/coverage
Browse files Browse the repository at this point in the history
add some more coverage
  • Loading branch information
davidhewitt authored Aug 10, 2024
2 parents 1b5c844 + 96f52ad commit 2595552
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,4 +793,39 @@ mod test {
let _: i128 = depythonize(&i128::MIN.into_py(py).into_bound(py)).unwrap();
});
}

#[test]
fn test_deserialize_bytes() {
Python::with_gil(|py| {
let obj = PyBytes::new_bound(py, "hello".as_bytes());
let actual: Vec<u8> = depythonize(&obj).unwrap();
assert_eq!(actual, b"hello");
})
}

#[test]
fn test_char() {
let expected = 'a';
let expected_json = json!("a");
let code = "'a'";
test_de(code, &expected, &expected_json);
}

#[test]
fn test_unknown_type() {
Python::with_gil(|py| {
let obj = py
.import_bound("decimal")
.unwrap()
.getattr("Decimal")
.unwrap()
.call0()
.unwrap();
let err = depythonize::<serde_json::Value>(&obj).unwrap_err();
assert!(matches!(
*err.inner,
ErrorImpl::UnsupportedType(name) if name == "Decimal"
));
});
}
}

0 comments on commit 2595552

Please sign in to comment.