aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-07-27 14:24:46 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2010-07-27 17:23:47 -0300
commit21460348ae4a73877ecbcc610d5ccd66a390d0c1 (patch)
tree30eca97f07cf325d8397958ff760b02244c660d3 /tests
parent7bd306347b8d55343e783a340f8bdc723111944f (diff)
BindingManager destructor now asserts if the wrapper map is empty.
The assertion is only used in debug mode. The duck punching test was altered to avoid failing when run with debug. Check the duck punching test file for a better explanation. Also added a debug helper method "showWrapperMap" to the binding manager, it shows the contents of the C pointer to Python wrapper mapping. Reviewed by Luciano Wolf <luciano.wolf@openbossa.org> Reviewed by Renato Ara├║jo <renato.filho@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/samplebinding/duck_punching_test.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/samplebinding/duck_punching_test.py b/tests/samplebinding/duck_punching_test.py
index cbf48c13..013e3646 100644
--- a/tests/samplebinding/duck_punching_test.py
+++ b/tests/samplebinding/duck_punching_test.py
@@ -68,6 +68,13 @@ class DuckPunchingTest(unittest.TestCase):
self.assertEqual(result1, result2)
self.assertEqual(result1, VirtualMethods.virtualMethod0(vm, pt, val, cpx, b) * self.multiplier)
+ # This is done to decrease the refcount of the vm object
+ # allowing the object wrapper to be deleted before the
+ # BindingManager. This is useful when compiling Shiboken
+ # for debug, since the BindingManager destructor has an
+ # assert that checks if the wrapper mapper is empty.
+ vm.virtualMethod0 = None
+
def testMonkeyPatchOnVirtualMethodWithInheritance(self):
'''Injects new 'virtualMethod0' on an object that inherits from VirtualMethods and makes C++ call it.'''
duck = Duck()
@@ -90,6 +97,8 @@ class DuckPunchingTest(unittest.TestCase):
self.assertEqual(result1, result2)
self.assertEqual(result1, VirtualMethods.virtualMethod0(duck, pt, val, cpx, b) * self.multiplier)
+ duck.virtualMethod0 = None
+
def testMonkeyPatchOnMethodWithStaticAndNonStaticOverloads(self):
'''Injects new 'exists' on a SimpleFile instance and makes C++ call it.'''
simplefile = SimpleFile('foobar')
@@ -112,6 +121,8 @@ class DuckPunchingTest(unittest.TestCase):
simplefile.exists()
self.assert_(self.duck_method_called)
+ simplefile.exists = None
+
def testMonkeyPatchOnMethodWithStaticAndNonStaticOverloadsWithInheritance(self):
'''Injects new 'exists' on an object that inherits from SimpleFile and makes C++ call it.'''
monkey = Monkey('foobar')
@@ -134,6 +145,8 @@ class DuckPunchingTest(unittest.TestCase):
monkey.exists()
self.assert_(self.duck_method_called)
+ monkey.exists = None
+
if __name__ == '__main__':
unittest.main()