aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-21 08:43:01 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-21 08:43:01 +0200
commit98eb59226aca550ae086c00b9c8023f47c44d2b2 (patch)
tree7e8a136347b5eb52ca0592b33aea09af97bf978a /sources/pyside2/tests
parent968e9adeccddfc7e3bc376e7b7606b376d8feecf (diff)
parent8728594d6b2e0f3df3e3726b67cf23715dfdcbe3 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Diffstat (limited to 'sources/pyside2/tests')
-rw-r--r--sources/pyside2/tests/QtUiTools/uiloader_test.py38
1 files changed, 20 insertions, 18 deletions
diff --git a/sources/pyside2/tests/QtUiTools/uiloader_test.py b/sources/pyside2/tests/QtUiTools/uiloader_test.py
index 48b401426..2fceb45c1 100644
--- a/sources/pyside2/tests/QtUiTools/uiloader_test.py
+++ b/sources/pyside2/tests/QtUiTools/uiloader_test.py
@@ -39,18 +39,25 @@ from helper.usesqapplication import UsesQApplication
from PySide2.QtWidgets import QWidget
from PySide2.QtUiTools import QUiLoader
-def get_file_path():
- for path in file_path:
- if os.path.exists(path):
- return path
- return ""
-class QUioaderTeste(UsesQApplication):
+class OverridingLoader(QUiLoader):
+ def createWidget(self, class_name, parent=None, name=''):
+ if class_name == 'QWidget':
+ w = QWidget(parent)
+ w.setObjectName(name)
+ return w
+ return QUiLoader.createWidget(self, class_name, parent, name)
+
+
+class QUiLoaderTester(UsesQApplication):
+ def setUp(self):
+ UsesQApplication.setUp(self)
+ self._filePath = os.path.join(os.path.dirname(__file__), 'test.ui')
+
def testLoadFile(self):
- filePath = os.path.join(os.path.dirname(__file__), 'test.ui')
loader = QUiLoader()
parent = QWidget()
- w = loader.load(filePath, parent)
+ w = loader.load(self._filePath, parent)
self.assertNotEqual(w, None)
self.assertEqual(len(parent.children()), 1)
@@ -59,18 +66,13 @@ class QUioaderTeste(UsesQApplication):
self.assertNotEqual(child, None)
self.assertEqual(w.findChild(QWidget, "grandson_object"), child.findChild(QWidget, "grandson_object"))
- def testLoadFileUnicodeFilePath(self):
- filePath = str(os.path.join(os.path.dirname(__file__), 'test.ui'))
- loader = QUiLoader()
- parent = QWidget()
- w = loader.load(filePath, parent)
- self.assertNotEqual(w, None)
- self.assertEqual(len(parent.children()), 1)
+ def testLoadFileOverride(self):
+ # PYSIDE-1070, override QUiLoader::createWidget() with parent=None crashes
+ loader = OverridingLoader()
+ w = loader.load(self._filePath)
+ self.assertNotEqual(w, None)
- child = w.findChild(QWidget, "child_object")
- self.assertNotEqual(child, None)
- self.assertEqual(w.findChild(QWidget, "grandson_object"), child.findChild(QWidget, "grandson_object"))
if __name__ == '__main__':
unittest.main()