aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/tests/QtCore
diff options
context:
space:
mode:
authorCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2018-01-29 15:09:03 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2018-02-01 06:48:01 +0000
commit71aa687341b8f4c0ad927b4d9fc60a1aaab6eab3 (patch)
tree5bf3b066122180ec4a1191ce0908526b4276137a /sources/pyside2/tests/QtCore
parentcc9950a7dc15c533529b34f1b6b9737c7c19fec0 (diff)
Fix error with second Qt.UniqueConnection call
The current implementation was considering only Py_True as a success, but not Py_False. The else statement will enter just in case of error, as intended. Added a test case to verify the proper behavior of Qt.UniqueConnection. Task-number: PYSIDE-34 Change-Id: I5bafe0e81383022dcd7fc6251fc61d0ab5e918d0 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/pyside2/tests/QtCore')
-rw-r--r--sources/pyside2/tests/QtCore/qobject_test.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/sources/pyside2/tests/QtCore/qobject_test.py b/sources/pyside2/tests/QtCore/qobject_test.py
index 482ae78be..bafa8a643 100644
--- a/sources/pyside2/tests/QtCore/qobject_test.py
+++ b/sources/pyside2/tests/QtCore/qobject_test.py
@@ -34,7 +34,12 @@
import unittest
import py3kcompat as py3k
-from PySide2.QtCore import QObject
+from PySide2.QtCore import QObject, Signal, Qt
+
+class Obj(QObject):
+ signal = Signal()
+ def empty(self):
+ pass
class ObjectNameCase(unittest.TestCase):
'''Tests related to QObject object name'''
@@ -67,6 +72,12 @@ class ObjectNameCase(unittest.TestCase):
obj.setObjectName(name)
self.assertEqual(obj.objectName(), name)
+ def testUniqueConnection(self):
+ obj = Obj()
+ # On first connect, UniqueConnection returns True, and on the second
+ # it must return False, and not a RuntimeError (PYSIDE-34)
+ self.assertTrue(obj.signal.connect(obj.empty, Qt.UniqueConnection))
+ self.assertFalse(obj.signal.connect(obj.empty, Qt.UniqueConnection))
if __name__ == '__main__':
unittest.main()