diff options
author | Renato Filho <renato.filho@openbossa.org> | 2010-07-09 10:31:37 -0300 |
---|---|---|
committer | Renato Filho <renato.filho@openbossa.org> | 2010-07-09 11:06:03 -0300 |
commit | 4090ef81efcada5bd6f882e1c91cd3a699c9c034 (patch) | |
tree | d366d403d4680ced9221834a86a257124924f435 /tests | |
parent | f1bbc25546b688e8a0766212a24f2d1eacc826c7 (diff) |
Restore missing function on QStandardItemModel.
Created unit test.
Fixes bug: #257.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/QtGui/qstandarditemmodel_test.py | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/tests/QtGui/qstandarditemmodel_test.py b/tests/QtGui/qstandarditemmodel_test.py index d83d856da..6ab86dd04 100644 --- a/tests/QtGui/qstandarditemmodel_test.py +++ b/tests/QtGui/qstandarditemmodel_test.py @@ -1,7 +1,7 @@ import unittest +import sys -from PySide.QtGui import * -from PySide.QtCore import * +from PySide.QtGui import QStandardItemModel, QWidget, QStandardItem from helper import UsesQApplication @@ -21,6 +21,43 @@ class QStandardItemModelTest(UsesQApplication): # bug #227 self.model.insertRow(0) + +class QStandardItemModelRef(UsesQApplication): + def testRefCount(self): + model = QStandardItemModel(5, 5) + items = [] + for r in range(5): + row = [] + for c in range(5): + row.append(QStandardItem("%d,%d" % (r,c)) ) + self.assertEqual(sys.getrefcount(row[c]), 2) + + model.insertRow(r, row) + + for c in range(5): + ref_after = sys.getrefcount(row[c]) + # check if the ref count was incremented after insertRow + self.assertEqual(ref_after, 3) + + items.append(row) + row = None + + for r in range(3): + my_row = model.takeRow(0) + my_row = None + for c in range(5): + # only rest 1 reference + self.assertEqual(sys.getrefcount(items[r][c]), 2) + + my_i = model.item(0,0) + # ref(my_i) + parent_ref + items list ref + self.assertEqual(sys.getrefcount(my_i), 4) + + model.clear() + # ref(my_i) + self.assertEqual(sys.getrefcount(my_i), 3) + + if __name__ == '__main__': unittest.main() |