mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-29 16:37:13 +00:00
Adding test_multiple_registered_instances_for_same_pointee_recursive.
This commit is contained in:
parent
a021e045a9
commit
5af253d66c
@ -1,6 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
import env # noqa: F401
|
||||||
|
|
||||||
|
import weakref
|
||||||
|
|
||||||
import pybind11_tests.class_sh_trampoline_shared_from_this as m
|
import pybind11_tests.class_sh_trampoline_shared_from_this as m
|
||||||
|
|
||||||
|
|
||||||
@ -187,6 +191,28 @@ def test_multiple_registered_instances_for_same_pointee_leak():
|
|||||||
break # Comment out for manual leak checking (use `top` command).
|
break # Comment out for manual leak checking (use `top` command).
|
||||||
|
|
||||||
|
|
||||||
|
def test_multiple_registered_instances_for_same_pointee_recursive():
|
||||||
|
while True:
|
||||||
|
obj0 = PySft("PySft")
|
||||||
|
if not env.PYPY:
|
||||||
|
obj0_wr = weakref.ref(obj0)
|
||||||
|
obj = obj0
|
||||||
|
# This loop creates a chain of instances linked by shared_ptrs.
|
||||||
|
for _ in range(10):
|
||||||
|
obj_next = m.Sft(obj)
|
||||||
|
assert obj_next is not obj
|
||||||
|
obj = obj_next
|
||||||
|
del obj_next
|
||||||
|
assert obj.history == "PySft"
|
||||||
|
del obj0
|
||||||
|
if not env.PYPY:
|
||||||
|
assert obj0_wr() is not None
|
||||||
|
del obj # This releases the chain recursively.
|
||||||
|
if not env.PYPY:
|
||||||
|
assert obj0_wr() is None
|
||||||
|
break # Comment out for manual leak checking (use `top` command).
|
||||||
|
|
||||||
|
|
||||||
def test_std_make_shared_factory():
|
def test_std_make_shared_factory():
|
||||||
class PySftMakeShared(m.Sft):
|
class PySftMakeShared(m.Sft):
|
||||||
def __init__(self, history):
|
def __init__(self, history):
|
||||||
|
Loading…
Reference in New Issue
Block a user