Fixing "wrong number of arguments" tests
This commit is contained in:
parent
859cec5632
commit
976cbf0029
1 changed files with 20 additions and 10 deletions
|
|
@ -5,7 +5,7 @@
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from PySide.QtCore import QObject, QTimer, QCoreApplication, SIGNAL, SLOT
|
from PySide.QtCore import QObject, QTimer, QCoreApplication, SIGNAL, SLOT, QProcess
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PySide.QtGui import QSpinBox, QPushButton, QApplication
|
from PySide.QtGui import QSpinBox, QPushButton, QApplication
|
||||||
|
|
@ -14,7 +14,7 @@ except ImportError:
|
||||||
QPushButton = object
|
QPushButton = object
|
||||||
QApplication = object
|
QApplication = object
|
||||||
|
|
||||||
from helper import BasicPySlotCase, UsesQApplication
|
from helper import BasicPySlotCase, UsesQApplication, UsesQCoreApplication
|
||||||
from helper.decorators import requires
|
from helper.decorators import requires
|
||||||
|
|
||||||
@requires('PySide.QtGui')
|
@requires('PySide.QtGui')
|
||||||
|
|
@ -35,14 +35,6 @@ class ButtonPySlot(UsesQApplication, BasicPySlotCase):
|
||||||
button.emit(SIGNAL('clicked()'))
|
button.emit(SIGNAL('clicked()'))
|
||||||
self.assert_(self.called)
|
self.assert_(self.called)
|
||||||
|
|
||||||
def testButtonClickedWrongArgs(self):
|
|
||||||
"""Python slot connected to QPushButton.clicked() and more args"""
|
|
||||||
button = QPushButton('Mylabel')
|
|
||||||
QObject.connect(button, SIGNAL('clicked()'), self.cb)
|
|
||||||
self.args = tuple()
|
|
||||||
button.emit(SIGNAL('clicked()'), 44)
|
|
||||||
self.assert_(self.called)
|
|
||||||
|
|
||||||
def testButtonClick(self):
|
def testButtonClick(self):
|
||||||
"""Indirect qt signal emission using the QPushButton.click() method """
|
"""Indirect qt signal emission using the QPushButton.click() method """
|
||||||
button = QPushButton('label')
|
button = QPushButton('label')
|
||||||
|
|
@ -126,5 +118,23 @@ class QSpinBoxQtSlots(UsesQApplication):
|
||||||
self.assertEqual(spinSend.value(), 42)
|
self.assertEqual(spinSend.value(), 42)
|
||||||
|
|
||||||
|
|
||||||
|
class ArgsOnEmptySignal(UsesQCoreApplication):
|
||||||
|
'''Trying to emit a signal without arguments passing some arguments'''
|
||||||
|
|
||||||
|
def testArgsToNoArgsSignal(self):
|
||||||
|
'''Passing arguments to a signal without arguments'''
|
||||||
|
process = QProcess()
|
||||||
|
self.assertRaises(TypeError, process.emit, SIGNAL('started()'), 42)
|
||||||
|
|
||||||
|
|
||||||
|
class MoreArgsOnEmit(UsesQCoreApplication):
|
||||||
|
'''Trying to pass more args than needed to emit (signals with args)'''
|
||||||
|
|
||||||
|
def testMoreArgs(self):
|
||||||
|
'''Passing more arguments than needed'''
|
||||||
|
process = QProcess()
|
||||||
|
self.assertRaises(TypeError, process.emit, SIGNAL('finished(int)'), 55, 55)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue