diff options
| author | Christian Tismer <tismer@stackless.com> | 2023-04-12 00:20:11 +0200 |
|---|---|---|
| committer | Christian Tismer <tismer@stackless.com> | 2023-04-12 14:11:57 +0200 |
| commit | e99951fc69c9f74001d577b291a48f3fd582427f (patch) | |
| tree | a657b80ab853c1c618e4bbe7d07a2106da64353e /sources/pyside6/tests/pysidetest/multiple_inheritance_test.py | |
| parent | e20e1ea0f5f9f9a0fe1c309a60cb5297f1276efc (diff) | |
Implement multiple inheritance correctly, amended
In multiple inheritance, it makes no sense to pass positional
arguments into a mixin class. This was correctly implemented
but later "corrected" because of wrong user input.
Correct and compatible to the competitor's implementation
is passing keyword arguments, only.
This is rarely a problem since people should use keyword arguments
only in multiple inheritance.
Change-Id: If5eb19368a50ee2a5534f10081d84511453993e5
Fixes: PYSIDE-2294
Pick-to: 6.5
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/pyside6/tests/pysidetest/multiple_inheritance_test.py')
| -rw-r--r-- | sources/pyside6/tests/pysidetest/multiple_inheritance_test.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sources/pyside6/tests/pysidetest/multiple_inheritance_test.py b/sources/pyside6/tests/pysidetest/multiple_inheritance_test.py index 6e48ac735..033a065ab 100644 --- a/sources/pyside6/tests/pysidetest/multiple_inheritance_test.py +++ b/sources/pyside6/tests/pysidetest/multiple_inheritance_test.py @@ -12,6 +12,7 @@ init_test_paths(False) from helper.usesqapplication import UsesQApplication from PySide6 import QtCore, QtGui, QtWidgets +from PySide6.QtWidgets import QMainWindow, QLabel def xprint(*args, **kw): @@ -100,6 +101,19 @@ class I(G, H, QtWidgets.QLabel): pass +# PYSIDE-2294: Friedemann's test adapted. +# We need to ignore positional args in mixin classes. +class Ui_X_MainWindow(object): # Emulating uic + def setupUi(self, MainWindow): + MainWindow.resize(400, 300) + self.lbl = QLabel(self) + +class MainWindow(QMainWindow, Ui_X_MainWindow): + def __init__(self, parent=None): + super().__init__(parent) + self.setupUi(self) + + class AdditionalMultipleInheritanceTest(UsesQApplication): def testABC(self): @@ -123,5 +137,11 @@ class AdditionalMultipleInheritanceTest(UsesQApplication): self.assertEqual(res.age, 7) xprint() + def testParentDoesNotCrash(self): + # This crashed with + # TypeError: object.__init__() takes exactly one argument (the instance to initialize) + MainWindow() + + if __name__ == "__main__": unittest.main() |
