aboutsummaryrefslogtreecommitdiffstats
path: root/tests/signals
diff options
context:
space:
mode:
authorLauro Neto <lauro.neto@openbossa.org>2009-12-12 16:58:39 -0300
committerLauro Neto <lauro.neto@openbossa.org>2009-12-16 21:14:24 -0300
commit1c087643b4c5856c12d8a4cd738ee93502310ca2 (patch)
treed1097e7c2553eb12ba43333064d52966ff1ea0b5 /tests/signals
parent477a17fb1bdbd83210c62c163691da790e4a304d (diff)
Fixing multiple signal tests
Changed to use a emitter argument to run_many, so we can pass qpushbutton.click or a partial call for python signals
Diffstat (limited to 'tests/signals')
-rw-r--r--tests/signals/multiple_connections_test.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/signals/multiple_connections_test.py b/tests/signals/multiple_connections_test.py
index f8dab32d5..169ecff70 100644
--- a/tests/signals/multiple_connections_test.py
+++ b/tests/signals/multiple_connections_test.py
@@ -1,6 +1,7 @@
import unittest
import random
+from functools import partial
from PySide.QtCore import QObject, SIGNAL
from PySide.QtGui import QPushButton, QSpinBox, QApplication
@@ -15,10 +16,11 @@ class MultipleSignalConnections(UsesQApplication):
qapplication = True
- def run_many(self, sender, signal, receivers, args=None):
+ def run_many(self, sender, signal, emitter, receivers, args=None):
"""Utility method to connect a list of receivers to a signal.
sender - QObject that will emit the signal
signal - string with the signal signature
+ emitter - the callable that will trigger the signal
receivers - list of BasicPySlotCase instances
args - tuple with the arguments to be sent.
"""
@@ -31,7 +33,7 @@ class MultipleSignalConnections(UsesQApplication):
QObject.connect(sender, SIGNAL(signal), rec.cb)
rec.args = tuple(args)
- sender.emit(SIGNAL(signal), *args)
+ emitter(*args)
for rec in receivers:
self.assert_(rec.called)
@@ -40,15 +42,16 @@ class MultipleSignalConnections(UsesQApplication):
"""Multiple connections to QPushButton.clicked()"""
sender = QPushButton('button')
receivers = [BasicPySlotCase() for x in range(30)]
- self.run_many(sender, 'clicked()', receivers)
+ self.run_many(sender, 'clicked()', sender.click, receivers)
def testSpinBoxValueChanged(self):
"""Multiple connections to QSpinBox.valueChanged(int)"""
- for test in random_gen(30):
+ for test in random_gen(10):
sender = QSpinBox()
#FIXME if number of receivers if higher than 50, segfaults
receivers = [BasicPySlotCase() for x in range(10)]
- self.run_many(sender, 'valueChanged(int)', receivers, (test,))
+ self.run_many(sender, 'valueChanged(int)', sender.setValue,
+ receivers, (test,))
def testPythonSignal(self):
"""Multiple connections to a python signal (short-circuit)"""
@@ -58,7 +61,8 @@ class MultipleSignalConnections(UsesQApplication):
for test in random_gen(30):
sender = Dummy()
receivers = [BasicPySlotCase() for x in range(10)]
- self.run_many(sender, 'foobar', receivers, (test, ))
+ self.run_many(sender, 'foobar', partial(sender.emit,
+ SIGNAL('foobar')), receivers, (test, ))
if __name__ == '__main__':
unittest.main()