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

Function test_insert

src/objects/list.rs:222–234  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

220
221 #[test]
222 fn test_insert() {
223 let gil = Python::acquire_gil();
224 let py = gil.python();
225 let v = vec![2, 3, 5, 7];
226 let list = v.to_py_object(py);
227 let val = 42i32.to_py_object(py).into_object();
228 assert_eq!(4, list.len(py));
229 assert_eq!(2, list.get_item(py, 0).extract::<i32>(py).unwrap());
230 list.insert(py, 0, val);
231 assert_eq!(5, list.len(py));
232 assert_eq!(42, list.get_item(py, 0).extract::<i32>(py).unwrap());
233 assert_eq!(2, list.get_item(py, 1).extract::<i32>(py).unwrap());
234 }
235
236 #[test]
237 fn test_append() {

Callers

nothing calls this directly

Calls 4

pythonMethod · 0.80
insertMethod · 0.80
to_py_objectMethod · 0.45
into_objectMethod · 0.45

Tested by

no test coverage detected