diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-06-29 10:18:19 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-06-30 16:41:52 +0200 |
commit | 8e81ff9bf06043713a0f5f3727d52bc7ddf29dba (patch) | |
tree | 15dd5529de8c3b7baf69357d724366dd8a55dd87 /sources | |
parent | 5054038dd43fbb243e2c44b0a9aad35181b043b1 (diff) |
PySide6: Add a test for QObject.findChildren() by type
Also test Python-derived types.
Task-number: PYSIDE-1609
Change-Id: Ia85a64ffc713c8cbbca0506dd9390f601e206e15
Reviewed-by: Christian Tismer <tismer@stackless.com>
(cherry picked from commit ba819888cad86b0cacb2a992f01287b476b29a04)
Diffstat (limited to 'sources')
-rw-r--r-- | sources/pyside2/tests/QtCore/qobject_parent_test.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sources/pyside2/tests/QtCore/qobject_parent_test.py b/sources/pyside2/tests/QtCore/qobject_parent_test.py index 0a02fbc26..becc7c48e 100644 --- a/sources/pyside2/tests/QtCore/qobject_parent_test.py +++ b/sources/pyside2/tests/QtCore/qobject_parent_test.py @@ -39,6 +39,16 @@ init_test_paths(False) from PySide2.QtCore import * +class TestObject1(QTimer): + def __init(self, parent): + super().__init__(parent) + + +class TestObject2(TestObject1): + def __init(self, parent): + super().__init__(parent) + + class ParentRefCountCase(unittest.TestCase): '''Test case for the refcount changes of setParent''' @@ -158,6 +168,26 @@ class ParentCase(unittest.TestCase): child = QObject(parent) self.assertEqual(parent, child.parent()) + def testFindChildByType(self): + parent = QObject() + expected = TestObject2(parent) + actual = parent.findChild(TestObject2) + self.assertEqual(actual, expected) + actual = parent.findChild(TestObject1) + self.assertEqual(actual, expected) + actual = parent.findChild(QTimer) + self.assertEqual(actual, expected) + + def testFindChildrenByType(self): + parent = QObject() + expected = [TestObject2(parent)] + actual = parent.findChildren(TestObject2) + self.assertEqual(actual, expected) + actual = parent.findChildren(TestObject1) + self.assertEqual(actual, expected) + actual = parent.findChildren(QTimer) + self.assertEqual(actual, expected) + class TestParentOwnership(unittest.TestCase): '''Test case for Parent/Child object ownership''' |