MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / panicking

Function panicking

tests/test_function.rs:188–206  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

186/// contains the panic’s payload, if that payload was a string.
187#[test]
188fn panicking() {
189 fn f(_py: Python) -> PyResult<PyNone> {
190 panic!("panicking because {}", "reasons")
191 }
192
193 let gil = Python::acquire_gil();
194 let py = gil.python();
195 let obj = py_fn!(py, f());
196
197 assert_eq!(
198 obj.call(py, NoArgs, None)
199 .unwrap_err() // Expect an exception
200 .instance(py)
201 .str(py)
202 .unwrap()
203 .to_string_lossy(py),
204 "Rust panic: panicking because reasons"
205 );
206}
207
208/* TODO: reimplement flexible sig support
209#[test]

Callers

nothing calls this directly

Calls 1

pythonMethod · 0.80

Tested by

no test coverage detected