aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/signals/static_metaobject_test.py
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-04-03 13:44:51 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2024-04-09 13:20:13 +0200
commit140b7df1263e2d24d1fc69b8ad305e8189d1dadc (patch)
tree0f414ea7a55bd8407651ddb0441e0c05ed2e8f79 /sources/pyside6/tests/signals/static_metaobject_test.py
parentf619b4c45b042c3a656a80b57cb4f154ef15bd1a (diff)
Port signals tests to modern syntax
Use the modern syntax where appropriate. Some tests are left unmodified to at least test the syntax. As a drive-by, remove the hasQtGui import checks since widgets should be built when this is run. Pick-to: 6.7 Task-number: PYSIDE-2646 Change-Id: I9acf07d0b735009f6aff4a55382dae745d855786 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/pyside6/tests/signals/static_metaobject_test.py')
-rw-r--r--sources/pyside6/tests/signals/static_metaobject_test.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/sources/pyside6/tests/signals/static_metaobject_test.py b/sources/pyside6/tests/signals/static_metaobject_test.py
index 6b1372d54..d7bf73e44 100644
--- a/sources/pyside6/tests/signals/static_metaobject_test.py
+++ b/sources/pyside6/tests/signals/static_metaobject_test.py
@@ -14,13 +14,22 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6.QtCore import QObject, SIGNAL, Slot
+from PySide6.QtCore import QObject, Signal, Slot, SIGNAL
from helper.usesqapplication import UsesQApplication
+class Sender(QObject):
+
+ foo = Signal()
+ foo2 = Signal()
+
+
class MyObject(QObject):
+
+ foo2 = Signal()
+
def __init__(self, parent=None):
- QObject.__init__(self, parent)
+ super().__init__(parent)
self._slotCalledCount = 0
# this '@Slot()' is needed to get the right sort order in testSharedSignalEmission.
@@ -33,7 +42,8 @@ class MyObject(QObject):
class StaticMetaObjectTest(UsesQApplication):
def testSignalPropagation(self):
- o = MyObject()
+ """Old style, dynamic signal creation."""
+ o = QObject()
o2 = MyObject()
# SIGNAL foo not created yet
@@ -55,17 +65,17 @@ class StaticMetaObjectTest(UsesQApplication):
self.assertEqual(o.metaObject().indexOfSignal("foo()"), -1)
def testSharedSignalEmission(self):
- o = QObject()
+ o = Sender()
m = MyObject()
- o.connect(SIGNAL("foo2()"), m.mySlot)
- m.connect(SIGNAL("foo2()"), m.mySlot)
- o.emit(SIGNAL("foo2()"))
+ o.foo2.connect(m.mySlot)
+ m.foo2.connect(m.mySlot)
+ o.foo2.emit()
self.assertEqual(m._slotCalledCount, 1)
del o
# PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
gc.collect()
- m.emit(SIGNAL("foo2()"))
+ m.foo2.emit()
self.assertEqual(m._slotCalledCount, 2)