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

Function test_keep_alive_constructor

tests/test_call_policies.py:222–244  ·  view source on GitHub ↗
(capture)

Source from the content-addressed store, hash-verified

220
221@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
222def test_keep_alive_constructor(capture):
223 n_inst = ConstructorStats.detail_reg_inst()
224
225 with capture:
226 p = m.Parent(m.Child())
227 assert ConstructorStats.detail_reg_inst() == n_inst + 2
228 assert (
229 capture
230 == """
231 Allocating child.
232 Allocating parent.
233 """
234 )
235 with capture:
236 del p
237 assert ConstructorStats.detail_reg_inst() == n_inst
238 assert (
239 capture
240 == """
241 Releasing parent.
242 Releasing child.
243 """
244 )
245
246
247def test_call_guard():

Callers

nothing calls this directly

Calls 2

ParentMethod · 0.80
ChildMethod · 0.80

Tested by

no test coverage detected