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

Function test_seq_del_item

src/objects/sequence.rs:408–432  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

406
407 #[test]
408 fn test_seq_del_item() {
409 let gil = Python::acquire_gil();
410 let py = gil.python();
411 let v: Vec<i32> = vec![1, 1, 2, 3, 5, 8];
412 let seq = v
413 .to_py_object(py)
414 .into_object()
415 .cast_into::<PySequence>(py)
416 .unwrap();
417 assert!(seq.del_item(py, 10).is_err());
418 assert_eq!(1, seq.get_item(py, 0).unwrap().extract::<i32>(py).unwrap());
419 assert!(seq.del_item(py, 0).is_ok());
420 assert_eq!(1, seq.get_item(py, 0).unwrap().extract::<i32>(py).unwrap());
421 assert!(seq.del_item(py, 0).is_ok());
422 assert_eq!(2, seq.get_item(py, 0).unwrap().extract::<i32>(py).unwrap());
423 assert!(seq.del_item(py, 0).is_ok());
424 assert_eq!(3, seq.get_item(py, 0).unwrap().extract::<i32>(py).unwrap());
425 assert!(seq.del_item(py, 0).is_ok());
426 assert_eq!(5, seq.get_item(py, 0).unwrap().extract::<i32>(py).unwrap());
427 assert!(seq.del_item(py, 0).is_ok());
428 assert_eq!(8, seq.get_item(py, 0).unwrap().extract::<i32>(py).unwrap());
429 assert!(seq.del_item(py, 0).is_ok());
430 assert_eq!(0, seq.len(py).unwrap());
431 assert!(seq.del_item(py, 0).is_err());
432 }
433
434 #[test]
435 fn test_seq_index() {

Callers

nothing calls this directly

Calls 3

pythonMethod · 0.80
into_objectMethod · 0.45
to_py_objectMethod · 0.45

Tested by

no test coverage detected