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:
Marcelo Lira 2010-10-05 16:10:50 -03:00
commit 4b3b56acd7
9 changed files with 1694 additions and 5 deletions

View 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()