aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2011-01-03 13:43:29 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:48:07 -0300
commit1af0e9f4fe50537d18c07cfa05578d3242ce21c9 (patch)
treeb900c7519deb9be840774ea1e65b056c2e102622 /tests
parentba00068ce161bba9c62c0784876bcb38d252cd98 (diff)
Fixed QWidget.parent function.
Create unit test for bug 576. Fixes bug #576. Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Lauro Moura <lauro.neto@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/QtGui/CMakeLists.txt1
-rw-r--r--tests/QtGui/bug_576.py32
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt
index 4514731cd..8906a9318 100644
--- a/tests/QtGui/CMakeLists.txt
+++ b/tests/QtGui/CMakeLists.txt
@@ -26,6 +26,7 @@ PYSIDE_TEST(bug_546.py)
PYSIDE_TEST(bug_547.py)
PYSIDE_TEST(bug_549.py)
PYSIDE_TEST(bug_569.py)
+PYSIDE_TEST(bug_576.py)
PYSIDE_TEST(customproxywidget_test.py)
PYSIDE_TEST(deepcopy_test.py)
PYSIDE_TEST(float_to_int_implicit_conversion_test.py)
diff --git a/tests/QtGui/bug_576.py b/tests/QtGui/bug_576.py
new file mode 100644
index 000000000..b3c11a35c
--- /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()
+