mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-11 16:13:53 +00:00
Inserting additional assert to ensure a returned unique_ptr is always a new Python instance.
This commit is contained in:
parent
ec86f10038
commit
a72e5f0c8f
@ -70,7 +70,13 @@ def test_pass_unique_ptr_disowns(pass_mpty, argm, rtrn):
|
|||||||
|
|
||||||
|
|
||||||
def test_unique_ptr_roundtrip(num_round_trips=1000):
|
def test_unique_ptr_roundtrip(num_round_trips=1000):
|
||||||
|
# Multiple roundtrips to stress-test instance registration/deregistration.
|
||||||
recycled = m.mpty("passenger")
|
recycled = m.mpty("passenger")
|
||||||
for _ in range(num_round_trips):
|
for _ in range(num_round_trips):
|
||||||
|
id_orig = id(recycled)
|
||||||
recycled = m.unique_ptr_roundtrip(recycled)
|
recycled = m.unique_ptr_roundtrip(recycled)
|
||||||
assert m.get_mtxt(recycled) == "passenger"
|
assert m.get_mtxt(recycled) == "passenger"
|
||||||
|
id_rtrn = id(recycled)
|
||||||
|
# Ensure the returned object is a different Python instance.
|
||||||
|
assert id_rtrn != id_orig
|
||||||
|
id_orig = id_rtrn
|
||||||
|
Loading…
Reference in New Issue
Block a user