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

Function test_unique_ptr_consumer_roundtrip

tests/test_class_sh_basic.py:189–204  ·  view source on GitHub ↗
(pass_f, rtrn_f, moved_out, moved_in)

Source from the content-addressed store, hash-verified

187 ],
188)
189def test_unique_ptr_consumer_roundtrip(pass_f, rtrn_f, moved_out, moved_in):
190 c = m.uconsumer()
191 assert not c.valid()
192 recycled = m.atyp("passenger")
193 mtxt_orig = m.get_mtxt(recycled)
194 assert re.match("passenger_(MvCtor){1,2}", mtxt_orig)
195
196 pass_f(c, recycled)
197 if moved_out:
198 with pytest.raises(ValueError) as excinfo:
199 m.get_mtxt(recycled)
200 assert "Python instance was disowned" in str(excinfo.value)
201
202 recycled = rtrn_f(c)
203 assert c.valid() != moved_in
204 assert m.get_mtxt(recycled) == mtxt_orig
205
206
207def test_py_type_handle_of_atyp():

Callers

nothing calls this directly

Calls 3

strClass · 0.85
validMethod · 0.80
atypMethod · 0.80

Tested by

no test coverage detected