Exemplo n.º 1
0
 def testDecideCallWithInheritance(self):
     """Call methods overloads that receive parent and inheritor classes' instances."""
     objecttype = ObjectType()
     objectmodel = ObjectModel()
     self.assertEqual(ObjectModel.receivesObjectTypeFamily(objecttype), ObjectModel.ObjectTypeCalled)
     self.assertNotEqual(ObjectModel.receivesObjectTypeFamily(objecttype), ObjectModel.ObjectModelCalled)
     self.assertEqual(ObjectModel.receivesObjectTypeFamily(objectmodel), ObjectModel.ObjectModelCalled)
     self.assertNotEqual(ObjectModel.receivesObjectTypeFamily(objectmodel), ObjectModel.ObjectTypeCalled)
Exemplo n.º 2
0
 def testDecideCallWithInheritance(self):
     '''Call methods overloads that receive parent and inheritor classes' instances.'''
     objecttype = ObjectType()
     objectmodel = ObjectModel()
     self.assertEqual(ObjectModel.receivesObjectTypeFamily(objecttype), ObjectModel.ObjectTypeCalled)
     self.assertNotEqual(ObjectModel.receivesObjectTypeFamily(objecttype), ObjectModel.ObjectModelCalled)
     self.assertEqual(ObjectModel.receivesObjectTypeFamily(objectmodel), ObjectModel.ObjectModelCalled)
     self.assertNotEqual(ObjectModel.receivesObjectTypeFamily(objectmodel), ObjectModel.ObjectTypeCalled)
Exemplo n.º 3
0
    def testReferenceCounting(self):
        '''Tests reference count of model-like object referred by view-like objects.'''
        model1 = ObjectModel()
        refcount1 = getrefcount(model1)
        view1 = ObjectView()
        view1.setModel(model1)
        self.assertEqual(getrefcount(view1.model()), refcount1 + 1)

        view2 = ObjectView()
        view2.setModel(model1)
        self.assertEqual(getrefcount(view2.model()), refcount1 + 2)

        model2 = ObjectModel()
        view2.setModel(model2)
        self.assertEqual(getrefcount(view1.model()), refcount1 + 1)
Exemplo n.º 4
0
    def testReferenceCountingWhenDeletingReferrer(self):
        '''Tests reference count of model-like object referred by deceased view-like object.'''
        model = ObjectModel()
        refcount1 = getrefcount(model)
        view = ObjectView()
        view.setModel(model)
        self.assertEqual(getrefcount(view.model()), refcount1 + 1)

        del view
        self.assertEqual(getrefcount(model), refcount1)
Exemplo n.º 5
0
 def createModelAndSetToView(view):
     model = ObjectModel()
     model.setObjectName('created model')
     view.setModel(model)
Exemplo n.º 6
0
 def createModelAndSetToView(view):
     model = ObjectModel()
     model.setObjectName("created model")
     view.setModel(model)
 def __init__(self, parent=None):
     ObjectModel.__init__(self, parent)
     self.obj = 0
Exemplo n.º 8
0
 def __init__(self, parent=None):
     ObjectModel.__init__(self, parent)
     self.obj = 0
Exemplo n.º 9
0
 def __init__(self, parent=None):
     ObjectModel.__init__(self, parent)
     self.obj = MyObject()
     self.obj.setObjectName(object_name)
Exemplo n.º 10
0
 def __init__(self, parent=None):
     ObjectModel.__init__(self, parent)
     self.obj = MyObject()
     self.obj.setObjectName(object_name)