Added tests for QObject properties being set with named arguments on the constructor.
Reviewed by Luciano Wolf <luciano.wolf@openbossa.org> Reviewed by Renato Araújo <renato.filho@openbossa.org>
This commit is contained in:
parent
2b21d79f54
commit
9a19bd26d2
1 changed files with 26 additions and 0 deletions
|
|
@ -13,6 +13,10 @@ class MySize(QSize):
|
||||||
'''Extended class'''
|
'''Extended class'''
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class ExtQObject(QObject):
|
||||||
|
registeredproperty = QProperty(int)
|
||||||
|
|
||||||
|
|
||||||
class PropertyCase(unittest.TestCase):
|
class PropertyCase(unittest.TestCase):
|
||||||
'''Test case for QObject properties'''
|
'''Test case for QObject properties'''
|
||||||
|
|
||||||
|
|
@ -91,5 +95,27 @@ class PropertyCase(unittest.TestCase):
|
||||||
|
|
||||||
self.assertTrue(obj.property('foo') is mysize)
|
self.assertTrue(obj.property('foo') is mysize)
|
||||||
|
|
||||||
|
|
||||||
|
class PropertyWithConstructorCase(unittest.TestCase):
|
||||||
|
'''Test case for QObject properties set using named arguments in the constructor.'''
|
||||||
|
|
||||||
|
def testObjectNameProperty(self):
|
||||||
|
#QObject(property=value) for existing C++ property
|
||||||
|
obj = QObject(objectName='dummy')
|
||||||
|
self.assertEqual(obj.objectName(), 'dummy')
|
||||||
|
|
||||||
|
def testDynamicPropertyRaisesException(self):
|
||||||
|
self.assertRaises(AttributeError, QObject, dummy=42)
|
||||||
|
|
||||||
|
def testPythonDeclaredProperty(self):
|
||||||
|
obj = ExtQObject(registeredproperty=123)
|
||||||
|
|
||||||
|
def testConstructorPropertyInQObjectDerived(self):
|
||||||
|
#QTimer(property=value) for existing C++ property
|
||||||
|
obj = QTimer(objectName='dummy')
|
||||||
|
self.assertEqual(obj.objectName(), 'dummy')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue