From a579744742430f656bbbbde8ce56754ce6ecc421 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Thu, 23 Aug 2007 23:48:34 +0100 Subject: [PATCH] test_subclassable_store_and_take_back --- examples/footest.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/examples/footest.py b/examples/footest.py index 392c96c..c5ae3ea 100644 --- a/examples/footest.py +++ b/examples/footest.py @@ -213,6 +213,27 @@ class TestFoo(unittest.TestCase): pass ## check that SomeObject was finally deleted self.assertEqual(foo.SomeObject.instance_count, count_before) + + def test_subclassable_store_and_take_back(self): + while gc.collect(): + pass + count_before = foo.SomeObject.instance_count + obj = foo.SomeObject("xxx") + foo.store_some_object(obj) + del obj + while gc.collect(): + pass + ## check that SomeObject isn't prematurely deleted + self.assertEqual(foo.SomeObject.instance_count, count_before + 1) + + ## now get the object back from the C side.. + obj = foo.take_some_object() + + del obj + while gc.collect(): + pass + ## check that SomeObject was finally deleted + self.assertEqual(foo.SomeObject.instance_count, count_before) def test_subclass_with_virtual_transfer_ptr(self):