Fix application of keep_alive policy to constructors (regression)
diff --git a/tests/test_call_policies.py b/tests/test_call_policies.py
index 6c60f81..7c83559 100644
--- a/tests/test_call_policies.py
+++ b/tests/test_call_policies.py
@@ -156,6 +156,25 @@
assert capture == "Releasing parent."
+def test_keep_alive_constructor(capture):
+ n_inst = ConstructorStats.detail_reg_inst()
+
+ with capture:
+ p = m.Parent(m.Child())
+ assert ConstructorStats.detail_reg_inst() == n_inst + 2
+ assert capture == """
+ Allocating child.
+ Allocating parent.
+ """
+ with capture:
+ del p
+ assert ConstructorStats.detail_reg_inst() == n_inst
+ assert capture == """
+ Releasing parent.
+ Releasing child.
+ """
+
+
def test_call_guard():
assert m.unguarded_call() == "unguarded"
assert m.guarded_call() == "guarded"