aboutsummaryrefslogtreecommitdiffstats
path: root/tests/samplebinding
diff options
context:
space:
mode:
authorLauro Neto <lauro.neto@openbossa.org>2010-02-04 15:20:46 -0300
committerHugo Lima <hugo.lima@openbossa.org>2010-02-04 17:05:11 -0200
commit22f1f61fec7cff3721c895b3d3071943405c57fa (patch)
treeb7bba440e9125db317dde124d8e013cce2b94387 /tests/samplebinding
parent46ea7e162321028a786dfc02cc8325cb20f2d957 (diff)
Fix Weakreference support
- Flag for types with private destructor - Cleaning weakrefs in normal destructor Reviewed by Hugo Parente <hugo.lima@openbossa.org>
Diffstat (limited to 'tests/samplebinding')
-rwxr-xr-xtests/samplebinding/weakref_test.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/samplebinding/weakref_test.py b/tests/samplebinding/weakref_test.py
index bdf2a479a..390252d46 100755
--- a/tests/samplebinding/weakref_test.py
+++ b/tests/samplebinding/weakref_test.py
@@ -29,20 +29,32 @@
import weakref
import unittest
-from sample import ObjectType
+from sample import ObjectType, PrivateDtor
class WeakrefBasicTest(unittest.TestCase):
'''Simple test case of using a weakref'''
+ def setUp(self):
+ self.called = False
+
def cb(self, *args):
- print 'callback', args
self.called = True
def testBasic(self):
'''ObjectType weakref'''
obj = ObjectType()
ref = weakref.ref(obj, self.cb)
+ del obj
+ self.assert_(self.called)
+
+ def testPrivateDtor(self):
+ '''PrivateDtor weakref'''
+ obj = PrivateDtor.instance()
+ print obj
+ ref = weakref.ref(obj, self.cb)
+ del obj
+ self.assert_(self.called)
if __name__ == '__main__':