Split signal tests into gui and core tests
Can't use a QApplication and a QCoreApplication in the same process
This commit is contained in:
parent
359c973b42
commit
33c837a48d
7 changed files with 224 additions and 168 deletions
38
tests/signals/lambda_gui_test.py
Normal file
38
tests/signals/lambda_gui_test.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
'''Connecting lambda to gui signals'''
|
||||
|
||||
import unittest
|
||||
|
||||
from PySide.QtCore import QObject, SIGNAL
|
||||
|
||||
try:
|
||||
from PySide.QtGui import QSpinBox, QPushButton
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
from helper import UsesQApplication
|
||||
from helper import decorators
|
||||
|
||||
|
||||
@decorators.requires('PySide.QtGui')
|
||||
class QtGuiSigLambda(UsesQApplication):
|
||||
|
||||
def testButton(self):
|
||||
#Connecting a lambda to a QPushButton.clicked()
|
||||
obj = QPushButton('label')
|
||||
QObject.connect(obj, SIGNAL('clicked()'),
|
||||
lambda: setattr(obj, 'called', True))
|
||||
obj.click()
|
||||
self.assert_(obj.called)
|
||||
|
||||
def testSpinButton(self):
|
||||
#Connecting a lambda to a QPushButton.clicked()
|
||||
obj = QSpinBox()
|
||||
arg = 444
|
||||
QObject.connect(obj, SIGNAL('valueChanged(int)'),
|
||||
lambda x: setattr(obj, 'arg', 444))
|
||||
obj.setValue(444)
|
||||
self.assertEqual(obj.arg, arg)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue