Crate pyo3_testing
source ·Expand description
Simplifies testing of #[pyo3function]
s by enabling tests to be condensed to:
#[pyo3test]
#[pyo3import(py_adders: from adders import addone)]
fn test_pyo3test_simple_case() {
let result: isize = addone!(1);
assert_eq!(result, 2);
}
and for checking that the correct type of python Exception is raised:
#[pyo3test]
#[allow(unused_macros)]
#[pyo3import(py_adders: from adders import addone)]
fn test_raises() {
with_py_raises!(PyTypeError, { addone.call1(("4",)) });
}
Macros§
- A proc macro to implement the equivalent of pytest’s
with raises
context manager.
Attribute Macros§
- A proc macro to decorate tests, which removes boilerplate code required for testing pyO3-wrapped functions within rust.