Created unit test for bug #1006.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>
Marcelo Lira <marcelo.lira@openbossa.org>
This commit is contained in:
parent
3a0b98ef4b
commit
f367f0ada3
2 changed files with 44 additions and 0 deletions
|
|
@ -78,6 +78,7 @@ PYSIDE_TEST(bug_988.py)
|
||||||
PYSIDE_TEST(bug_991.py)
|
PYSIDE_TEST(bug_991.py)
|
||||||
PYSIDE_TEST(bug_998.py)
|
PYSIDE_TEST(bug_998.py)
|
||||||
PYSIDE_TEST(bug_1002.py)
|
PYSIDE_TEST(bug_1002.py)
|
||||||
|
PYSIDE_TEST(bug_1006.py)
|
||||||
PYSIDE_TEST(customproxywidget_test.py)
|
PYSIDE_TEST(customproxywidget_test.py)
|
||||||
PYSIDE_TEST(deepcopy_test.py)
|
PYSIDE_TEST(deepcopy_test.py)
|
||||||
PYSIDE_TEST(event_filter_test.py)
|
PYSIDE_TEST(event_filter_test.py)
|
||||||
|
|
|
||||||
43
tests/QtGui/bug_1006.py
Normal file
43
tests/QtGui/bug_1006.py
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
import unittest
|
||||||
|
import weakref
|
||||||
|
from PySide.QtCore import Qt
|
||||||
|
from PySide.QtGui import QDialog, QLabel, QGridLayout
|
||||||
|
|
||||||
|
from helper import TimedQApplication
|
||||||
|
|
||||||
|
class LabelWindow(QDialog):
|
||||||
|
def __init__(self, parent):
|
||||||
|
super(LabelWindow, self).__init__(parent)
|
||||||
|
|
||||||
|
self.test_layout = QGridLayout()
|
||||||
|
label = QLabel("Label")
|
||||||
|
self.test_layout.addWidget(label, 0, 0)
|
||||||
|
self.setLayout(self.test_layout)
|
||||||
|
self._destroyCalled = False
|
||||||
|
|
||||||
|
|
||||||
|
def replace(self):
|
||||||
|
old_item = self.test_layout.itemAtPosition(0, 0)
|
||||||
|
ref = weakref.ref(old_item, self._destroyed)
|
||||||
|
old_label = old_item.widget()
|
||||||
|
del old_item
|
||||||
|
|
||||||
|
self.test_layout.removeWidget(old_label)
|
||||||
|
label = QLabel("Label New")
|
||||||
|
old_label.deleteLater()
|
||||||
|
label.setAlignment(Qt.AlignCenter)
|
||||||
|
self.test_layout.addWidget(label, 0, 0)
|
||||||
|
|
||||||
|
def _destroyed(self, obj):
|
||||||
|
self._destroyCalled = True
|
||||||
|
|
||||||
|
class TestBug1006 (TimedQApplication):
|
||||||
|
|
||||||
|
def testLayoutItemLifeTime(self):
|
||||||
|
window = LabelWindow(None)
|
||||||
|
window.replace()
|
||||||
|
self.assertTrue(window._destroyCalled)
|
||||||
|
self.app.exec_()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue