MCPcopy Create free account
hub / github.com/pybind/pybind11 / assert_keeps_alive

Function assert_keeps_alive

tests/test_eigen_matrix.py:400–412  ·  view source on GitHub ↗
(cl, method, *args)

Source from the content-addressed store, hash-verified

398
399@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
400def assert_keeps_alive(cl, method, *args):
401 cstats = ConstructorStats.get(cl)
402 start_with = cstats.alive()
403 a = cl()
404 assert cstats.alive() == start_with + 1
405 z = method(a, *args)
406 assert cstats.alive() == start_with + 1
407 del a
408 # Here's the keep alive in action:
409 assert cstats.alive() == start_with + 1
410 del z
411 # Keep alive should have expired:
412 assert cstats.alive() == start_with
413
414
415@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")

Callers 1

test_eigen_keepaliveFunction · 0.85

Calls 2

aliveMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected