aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2011-01-12 19:30:23 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:12:53 -0300
commit0eef7934bc0dc0a3b915c1502bfc0be60d7eb365 (patch)
tree4c935849806a1424f434a18e0e6290d05e300f1a /tests
parenta260a414d8c875fbeda2862ce8adf7ddc1a9be3c (diff)
Optimized setParent function.
Replaced use of find in the children list for check on the current child if his has a parent and if the parent is the same. Fixes bug #556 Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Hugo Parente <hugo.lima@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/samplebinding/ownership_reparenting_test.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/samplebinding/ownership_reparenting_test.py b/tests/samplebinding/ownership_reparenting_test.py
index 3e68287b0..395ce393a 100644
--- a/tests/samplebinding/ownership_reparenting_test.py
+++ b/tests/samplebinding/ownership_reparenting_test.py
@@ -27,6 +27,7 @@
'''Tests for object reparenting.'''
import unittest
+import sys
from sample import ObjectType
@@ -52,6 +53,15 @@ class ReparentingTest(unittest.TestCase):
for child in new_parent.children():
self.assert_(child in object_list)
+ def testReparentWithTheSameParent(self):
+ '''Set the same parent twice to check if the ref continue the same'''
+ obj = ObjectType()
+ parent = ObjectType()
+ self.assertEqual(sys.getrefcount(obj), 2)
+ obj.setParent(parent)
+ self.assertEqual(sys.getrefcount(obj), 3)
+ obj.setParent(parent)
+ self.assertEqual(sys.getrefcount(obj), 3)
def testReparentedExtObjectType(self):
'''Reparent children from one extended parent to another.'''