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

Function test_reallocation_a

tests/test_factory_constructors.py:360–379  ·  view source on GitHub ↗

When the constructor is overloaded, previous overloads can require a preallocated value. This test makes sure that such preallocated values only happen when they might be necessary, and that they are deallocated properly.

(capture, msg)

Source from the content-addressed store, hash-verified

358
359@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
360def test_reallocation_a(capture, msg):
361 """When the constructor is overloaded, previous overloads can require a preallocated value.
362 This test makes sure that such preallocated values only happen when they might be necessary,
363 and that they are deallocated properly."""
364
365 pytest.gc_collect()
366
367 with capture:
368 create_and_destroy(1)
369 assert (
370 msg(capture)
371 == """
372 noisy new
373 noisy placement new
374 NoisyAlloc(int 1)
375 ---
376 ~NoisyAlloc()
377 noisy delete
378 """
379 )
380
381
382@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")

Callers

nothing calls this directly

Calls 2

create_and_destroyFunction · 0.85
msgFunction · 0.85

Tested by

no test coverage detected