aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtGui/bug_576.py
blob: b3c11a35c10af69c53fb4a79b9ded8cc69f821ec (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
""" Unittest for bug #576 """
""" http://bugs.openbossa.org/show_bug.cgi?id=576 """

from PySide import QtGui, QtCore
import sys
import unittest

class Bug576(unittest.TestCase):
    def onButtonDestroyed(self, button):
        self._destroyed = True

    def testWidgetParent(self):
        self._destroyed = False
        app = QtGui.QApplication(sys.argv)
        w = QtGui.QWidget()

        b = QtGui.QPushButton("test")
        b.destroyed[QtCore.QObject].connect(self.onButtonDestroyed)
        self.assertEqual(sys.getrefcount(b), 2)
        b.setParent(w)
        self.assertEqual(sys.getrefcount(b), 3)
        b.parent()
        self.assertEqual(sys.getrefcount(b), 3)
        b.setParent(None)
        self.assertEqual(sys.getrefcount(b), 2)
        del b
        self.assert_(self._destroyed)


if __name__ == '__main__':
    unittest.main()