summaryrefslogtreecommitdiffstats
path: root/tests/QtGui/bug_576.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/QtGui/bug_576.py')
-rw-r--r--tests/QtGui/bug_576.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/QtGui/bug_576.py b/tests/QtGui/bug_576.py
new file mode 100644
index 0000000..b3c11a3
--- /dev/null
+++ b/tests/QtGui/bug_576.py
@@ -0,0 +1,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()
+