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

Function gc_integration

tests/test_class.rs:390–408  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

388
389#[test]
390fn gc_integration() {
391 let gil = Python::acquire_gil();
392 let py = gil.python();
393
394 let drop_called = Arc::new(AtomicBool::new(false));
395 let inst = GCIntegration::create_instance(
396 py,
397 RefCell::new(py.None()),
398 TestDropCall {
399 drop_called: drop_called.clone(),
400 },
401 )
402 .unwrap();
403 *inst.self_ref(py).borrow_mut() = inst.as_object().clone_ref(py);
404 inst.release_ref(py);
405
406 py.run("import gc; gc.collect()", None, None).unwrap();
407 assert!(drop_called.load(Ordering::Relaxed));
408}
409
410py_class!(class Len |py| {
411 data l: usize;

Callers

nothing calls this directly

Calls 8

pythonMethod · 0.80
NoneMethod · 0.80
borrow_mutMethod · 0.80
runMethod · 0.80
cloneMethod · 0.45
clone_refMethod · 0.45
as_objectMethod · 0.45
release_refMethod · 0.45

Tested by

no test coverage detected