pyo3/tests/test_string.rs

24 lines
536 B
Rust
Raw Normal View History

2021-12-03 00:03:32 +00:00
#![cfg(feature = "macros")]
use pyo3::prelude::*;
2023-09-24 12:34:53 +00:00
#[path = "../src/tests/common.rs"]
mod common;
#[pyfunction]
2021-02-11 21:37:38 +00:00
fn take_str(_s: &str) {}
#[test]
fn test_unicode_encode_error() {
2022-07-19 17:34:23 +00:00
Python::with_gil(|py| {
let take_str = wrap_pyfunction_bound!(take_str)(py).unwrap();
2022-07-19 17:34:23 +00:00
py_expect_exception!(
py,
take_str,
"take_str('\\ud800')",
PyUnicodeEncodeError,
"'utf-8' codec can't encode character '\\ud800' in position 0: surrogates not allowed"
);
});
}