From b719c4e8b9238ea8c4d1e022cf597e8cb628f5d7 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 12 Jan 2011 19:30:23 -0300 Subject: 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 Hugo Parente --- tests/samplebinding/ownership_reparenting_test.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/samplebinding') diff --git a/tests/samplebinding/ownership_reparenting_test.py b/tests/samplebinding/ownership_reparenting_test.py index 3e68287b..395ce393 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.''' -- cgit