File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1
1
# -*- coding: utf-8 -*-
2
2
import pytest
3
3
4
+ import env # noqa: F401
5
+
6
+ import weakref
7
+
4
8
import pybind11_tests .class_sh_trampoline_shared_from_this as m
5
9
6
10
@@ -187,6 +191,28 @@ def test_multiple_registered_instances_for_same_pointee_leak():
187
191
break # Comment out for manual leak checking (use `top` command).
188
192
189
193
194
+ def test_multiple_registered_instances_for_same_pointee_recursive ():
195
+ while True :
196
+ obj0 = PySft ("PySft" )
197
+ if not env .PYPY :
198
+ obj0_wr = weakref .ref (obj0 )
199
+ obj = obj0
200
+ # This loop creates a chain of instances linked by shared_ptrs.
201
+ for _ in range (10 ):
202
+ obj_next = m .Sft (obj )
203
+ assert obj_next is not obj
204
+ obj = obj_next
205
+ del obj_next
206
+ assert obj .history == "PySft"
207
+ del obj0
208
+ if not env .PYPY :
209
+ assert obj0_wr () is not None
210
+ del obj # This releases the chain recursively.
211
+ if not env .PYPY :
212
+ assert obj0_wr () is None
213
+ break # Comment out for manual leak checking (use `top` command).
214
+
215
+
190
216
def test_std_make_shared_factory ():
191
217
class PySftMakeShared (m .Sft ):
192
218
def __init__ (self , history ):
You can’t perform that action at this time.
0 commit comments