Added a PySide derived test library.
The test library is intended to provide specific test cases in a way that problems could be isolated easier than using the ones provided by the Qt library. Cases commons to all Python bindings must go into the Shiboken test libraries, the one added here is intended to test Qt specifics (e.g. signals). A Python unit test was added for the case when a method and a signal have the same name.
This commit is contained in:
parent
42516e6f86
commit
4b3b56acd7
9 changed files with 1694 additions and 5 deletions
53
tests/pysidetest/homonimoussignalandmethod_test.py
Normal file
53
tests/pysidetest/homonimoussignalandmethod_test.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import unittest
|
||||
from testbinding import TestObject
|
||||
|
||||
'''Tests the behaviour of homonimous signals and slots.'''
|
||||
|
||||
class HomonimousSignalAndMethodTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.value = 123
|
||||
self.called = False
|
||||
self.obj = TestObject(self.value)
|
||||
|
||||
def tearDown(self):
|
||||
del self.value
|
||||
del self.called
|
||||
del self.obj
|
||||
|
||||
def testIdValueSignalEmission(self):
|
||||
def callback(idValue):
|
||||
self.assertEqual(idValue, self.value)
|
||||
self.obj.idValue.connect(callback)
|
||||
self.obj.emitIdValueSignal()
|
||||
|
||||
def testStaticMethodDoubleSignalEmission(self):
|
||||
def callback():
|
||||
self.called = True
|
||||
self.obj.staticMethodDouble.connect(callback)
|
||||
self.obj.emitStaticMethodDoubleSignal()
|
||||
self.assert_(self.called)
|
||||
|
||||
def testSignalNotCallable(self):
|
||||
self.assertRaises(TypeError, self.obj.justASignal)
|
||||
|
||||
def testCallingInstanceMethodWithArguments(self):
|
||||
self.assertRaises(TypeError, TestObject.idValue, 1)
|
||||
|
||||
def testCallingInstanceMethodWithoutArguments(self):
|
||||
self.assertRaises(TypeError, TestObject.idValue)
|
||||
|
||||
def testHomonimousSignalAndMethod(self):
|
||||
self.assertEqual(self.obj.idValue(), self.value)
|
||||
|
||||
def testHomonimousSignalAndStaticMethod(self):
|
||||
self.assertEqual(TestObject.staticMethodDouble(3), 6)
|
||||
|
||||
def testHomonimousSignalAndStaticMethodFromInstance(self):
|
||||
self.assertEqual(self.obj.staticMethodDouble(4), 8)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue