aboutsummaryrefslogtreecommitdiffstats
path: root/tests/qtgui/parent_policy_test.py
blob: e90da5a49d01ae2d705ee90de622d9552df98dee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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()