def testReferreedObjectSurvivalAfterContextEnd(self):
     '''Model-like object assigned to a view-like object must survive after get out of context.'''
     def createModelAndSetToView(view):
         model = ObjectModel()
         model.setObjectName('created model')
         view.setModel(model)
     view = ObjectView()
     createModelAndSetToView(view)
     model = view.model()
Esempio n. 2
0
 def testReferreedObjectSurvivalAfterContextEnd(self):
     '''Model-like object assigned to a view-like object must survive after get out of context.'''
     def createModelAndSetToView(view):
         model = ObjectModel()
         model.setObjectName('created model')
         view.setModel(model)
     view = ObjectView()
     createModelAndSetToView(view)
     model = view.model()
Esempio n. 3
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)
Esempio 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)
Esempio n. 5
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)
Esempio n. 6
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)
 def testWrongTypeReturn(self):
     model = ListModelWrong()
     view = ObjectView(model)
     self.assertRaises(RuntimeWarning,
                       view.getRawModelData)  # calls model.data()
 def testListModelKeepsReference(self):
     model = ListModelKeepsReference()
     view = ObjectView(model)
     obj = view.getRawModelData()
     self.assertEqual(type(obj), MyObject)
     self.assertEqual(obj.objectName(), object_name)
Esempio n. 9
0
 def testListModelKeepsReference(self):
     model = ListModelKeepsReference()
     view = ObjectView(model)
     obj = view.getRawModelData()
     self.assertEqual(type(obj), MyObject)
     self.assertEqual(obj.objectName(), object_name)