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

Function test_buffer

tests/test_buffer_protocol.rs:49–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47
48#[test]
49fn test_buffer() {
50 let drop_called = Arc::new(AtomicBool::new(false));
51
52 Python::attach(|py| {
53 let instance = Py::new(
54 py,
55 TestBufferClass {
56 vec: vec![b' ', b'2', b'3'],
57 drop_called: drop_called.clone(),
58 },
59 )
60 .unwrap();
61 let env = [("ob", instance)].into_py_dict(py).unwrap();
62 py_assert!(py, *env, "bytes(ob) == b' 23'");
63 });
64
65 assert!(drop_called.load(Ordering::Relaxed));
66}
67
68#[test]
69fn test_buffer_referenced() {

Callers

nothing calls this directly

Calls 2

into_py_dictMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected