aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/QtCore/signal_sender.py
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/tests/QtCore/signal_sender.py')
-rw-r--r--sources/pyside6/tests/QtCore/signal_sender.py34
1 files changed, 31 insertions, 3 deletions
diff --git a/sources/pyside6/tests/QtCore/signal_sender.py b/sources/pyside6/tests/QtCore/signal_sender.py
index 208030058..2552591e5 100644
--- a/sources/pyside6/tests/QtCore/signal_sender.py
+++ b/sources/pyside6/tests/QtCore/signal_sender.py
@@ -10,9 +10,10 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from helper.usesqcoreapplication import UsesQCoreApplication
+from helper.usesqapplication import UsesQApplication
-from PySide6.QtCore import QCoreApplication, QObject, QTimer, Signal, Slot
+from PySide6.QtCore import (QCoreApplication, QObject, QStringListModel,
+ QTimer, Signal, Slot, Qt)
class Sender(QObject):
@@ -39,7 +40,7 @@ class DerivedReceiver(Receiver):
pass
-class TestSignalSender(UsesQCoreApplication):
+class TestSignalSender(UsesQApplication):
"""Test PYSIDE-2144/1295, check that QObject::sender() works also if it is
routed via GlobalReceiverV2 in case of a non-C++ slot (Python callback,
as for derived classes)."""
@@ -59,5 +60,32 @@ class TestSignalSender(UsesQCoreApplication):
self.assertEqual(derived_receiver._sender, sender)
+class TestConstructorConnection(UsesQApplication):
+ """PYSIDE-2329: Check constructor connections for signals from the
+ base as well as signals with arguments."""
+ def testConstructorConnection(self):
+
+ was_destroyed = False
+ was_changed = False
+
+ def destroyed_handler():
+ nonlocal was_destroyed
+ was_destroyed = True
+
+ def changed_handler():
+ nonlocal was_changed
+ was_changed = True
+
+ data_list = ["blub"]
+ model = QStringListModel(data_list,
+ destroyed=destroyed_handler,
+ dataChanged=changed_handler)
+ model.setData(model.index(0, 0), "bla", Qt.EditRole)
+ del model
+
+ self.assertTrue(was_changed)
+ self.assertTrue(was_destroyed)
+
+
if __name__ == '__main__':
unittest.main()