MCPcopy Create free account
hub / github.com/PyO3/pyo3 / test_buffer_add

Function test_buffer_add

tests/test_pyfunction.rs:131–159  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

129#[cfg(any(not(Py_LIMITED_API), Py_3_11))]
130#[test]
131fn test_buffer_add() {
132 Python::attach(|py| {
133 let f = wrap_pyfunction!(buffer_inplace_add)(py).unwrap();
134
135 py_expect_exception!(
136 py,
137 f,
138 r#"
139import array
140a = array.array("i", [0, 1, 2, 3])
141b = array.array("I", [0, 1, 2, 3])
142f(a, b)
143"#,
144 PyBufferError
145 );
146
147 pyo3::py_run!(
148 py,
149 f,
150 r#"
151import array
152a = array.array("i", [0, 1, 2, 3])
153b = array.array("i", [2, 3, 4, 5])
154f(a, b)
155assert a, array.array("i", [2, 4, 6, 8])
156"#
157 );
158 });
159}
160
161#[cfg(not(PyPy))]
162#[pyfunction]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected