aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtCore/qobject_destructor.py
blob: 036bf1d7603c466813ecf013b9b36cc5aa50f977 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import sys
import unittest
from PySide import QtCore

class MyObject(QtCore.QObject):
    def __init__(self, other=None):
        QtCore.QObject.__init__(self, None)
        self._o = other

class TestDestructor(unittest.TestCase):
    def testReference(self):
        o = QtCore.QObject()
        m = MyObject(o)
        self.assertEqual(sys.getrefcount(o), 3)
        del m
        self.assertEqual(sys.getrefcount(o), 2)

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