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

Function test_shared

tests/test_local_bindings.py:27–37  ·  view source on GitHub ↗
(val, ctor, loader)

Source from the content-addressed store, hash-verified

25 assert "incompatible function arguments" in str(excinfo.value)
26
27 def test_shared(val, ctor, loader):
28 obj = ctor(val)
29 with suppress(AttributeError): # non-cpython VMs don't have getrefcount
30 rc_before = sys.getrefcount(obj)
31 wrapper = loader(obj)
32 # wrapper holds a shared_ptr that keeps obj alive
33 assert wrapper.use_count == 1
34 assert wrapper.value == val
35 with suppress(AttributeError):
36 rc_after = sys.getrefcount(obj)
37 assert rc_after > rc_before
38
39 test_shared(220, cm.ExternalType2, m.load_external2_shared)
40 test_shared(330, cm.ExternalType3, m.load_external3_shared)

Callers 1

test_load_externalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected