File: test_string.rs

package info (click to toggle)
rust-pyo3 0.27.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,648 kB
  • sloc: javascript: 59; makefile: 58; python: 39; sh: 1
file content (22 lines) | stat: -rw-r--r-- 497 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#![cfg(feature = "macros")]

use pyo3::prelude::*;

mod test_utils;

#[pyfunction]
fn take_str(_s: &str) {}

#[test]
fn test_unicode_encode_error() {
    Python::attach(|py| {
        let take_str = wrap_pyfunction!(take_str)(py).unwrap();
        py_expect_exception!(
            py,
            take_str,
            "take_str('\\ud800')",
            PyUnicodeEncodeError,
            "'utf-8' codec can't encode character '\\ud800' in position 0: surrogates not allowed"
        );
    });
}