aboutsummaryrefslogtreecommitdiffstats
path: root/tests/qtgui/parent_policy_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/qtgui/parent_policy_test.py')
-rwxr-xr-xtests/qtgui/parent_policy_test.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/qtgui/parent_policy_test.py b/tests/qtgui/parent_policy_test.py
new file mode 100755
index 000000000..e90da5a49
--- /dev/null
+++ b/tests/qtgui/parent_policy_test.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+
+import unittest
+
+from helper import UsesQApplication
+from PySide.QtCore import QAbstractTableModel, QVariant
+from PySide.QtGui import QTableView
+
+class TestModel(QAbstractTableModel):
+ def __init__(self, parent=None):
+ QAbstractTableModel.__init__(self, parent)
+ def rowCount(self, parent):
+ return 0
+ def columnCount(self, parent):
+ return 0
+ def data(self, index, role):
+ return QVariant()
+
+class ParentPolicyTest(UsesQApplication):
+
+ def testModelWithoutParent(self):
+ view = QTableView()
+ model = TestModel()
+ view.setModel(model)
+ samemodel = view.model()
+ self.assertEqual(model, samemodel)
+
+ def testModelWithParent(self):
+ view = QTableView()
+ model = TestModel(self.app)
+ view.setModel(model)
+ samemodel = view.model()
+ self.assertEqual(model, samemodel)
+
+if __name__ == '__main__':
+ unittest.main()
+