def testIt(self): obj1 = HandleHolder() obj2 = HandleHolder() hash1 = hash(obj1) hash2 = hash(obj2) self.assertNotEqual(hash1, hash2) # Now invalidate the object and test its hash. It shouldn't segfault. shiboken.invalidate(obj1) hash1_2 = hash(obj1) self.assertEqual(hash1_2, hash1)
def testClassDecref(self): # Bug was that class PyTypeObject wasn't decrefed when instance # was invalidated before = sys.getrefcount(PrivateDtor) for i in range(1000): obj = PrivateDtor.instance() shiboken.invalidate(obj) after = sys.getrefcount(PrivateDtor) self.assertLess(abs(before - after), 5)
def testNextInFocusChainCycleList(self): '''As above but in for a list of objects''' parents = [] children = [] focus_chains = [] for i in range(10): parent = ObjectType() child = ObjectType(parent) next_focus = child.nextInFocusChain() parents.append(parent) children.append(child) focus_chains.append(next_focus) shiboken.invalidate(parents)
def testDump(self): """Just check if dump doesn't crash on certain use cases""" p = ObjectType() obj = ObjectType(p) obj2 = ObjectType(obj) obj3 = ObjectType(obj) self.assertEqual(shiboken.dump(None), "Ordinary Python type.") shiboken.dump(obj) model = ObjectModel(p) v = ObjectView(model, p) shiboken.dump(v) m = MultipleInherited() shiboken.dump(m) self.assertEqual(len(shiboken.getCppPointer(m)), 2) # Don't crash even after deleting an object shiboken.invalidate(obj) shiboken.dump(obj) # deleted shiboken.dump(p) # child deleted shiboken.dump(obj2) # parent deleted
def testNextInFocusChainCycle(self): parent = ObjectType() child = ObjectType(parent) next_focus = child.nextInFocusChain() shiboken.invalidate(parent)