aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-08-16 12:07:12 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-08-16 18:25:54 -0300
commit2d24d300d8ef7e65489051f2f6d3d7d213d4a86a (patch)
tree86843edbf588b292addd414630eccb3cb8380f09 /tests
parent6bd528978cad1fe2c0e56cb35b270346da3fbbdd (diff)
Avoid read the property in the QObject constructor.
Create unit test to verify if the python property is setted during the constructor. Reviewer: Hugo Parente <hugo.lima@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/QtCore/qobject_property_test.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/tests/QtCore/qobject_property_test.py b/tests/QtCore/qobject_property_test.py
index 7d53e0a26..1d8a16c9a 100644
--- a/tests/QtCore/qobject_property_test.py
+++ b/tests/QtCore/qobject_property_test.py
@@ -13,8 +13,17 @@ class MySize(QSize):
'''Extended class'''
pass
-class ExtQObject(QObject):
- registeredproperty = QProperty(int)
+class ExQObject(QObject):
+ def __init__(self, *args, **kargs):
+ QObject.__init__(self, *args, **kargs)
+
+ def setProperty(self, value):
+ self._value = value
+
+ def getProperty(self):
+ return self._value
+
+ registeredproperty = QProperty(int, getProperty, setProperty)
class MyObject(QObject):
'''Test Property'''
@@ -105,7 +114,6 @@ class PropertyCase(unittest.TestCase):
self.assertTrue(obj.property('foo') is mysize)
-
class PropertyWithConstructorCase(unittest.TestCase):
'''Test case for QObject properties set using named arguments in the constructor.'''
@@ -118,17 +126,17 @@ class PropertyWithConstructorCase(unittest.TestCase):
self.assertRaises(AttributeError, QObject, dummy=42)
def testPythonDeclaredProperty(self):
- obj = ExtQObject(registeredproperty=123)
+ obj = ExQObject(registeredproperty=123)
+ self.assertEqual(obj.registeredproperty, 123)
def testConstructorPropertyInQObjectDerived(self):
#QTimer(property=value) for existing C++ property
obj = QTimer(objectName='dummy')
self.assertEqual(obj.objectName(), 'dummy')
- def testPythonProperty(self):
+ def testReadOnlyPythonProperty(self):
o = MyObject()
self.assertEqual(o.pp, 42)
- o.pp = 0
self.assertRaises(AttributeError, o.trySetPP)
if __name__ == '__main__':