diff options
author | Renato Filho <renato.filho@openbossa.org> | 2010-08-13 18:22:22 -0300 |
---|---|---|
committer | Renato Filho <renato.filho@openbossa.org> | 2010-08-16 10:48:42 -0300 |
commit | 6bd528978cad1fe2c0e56cb35b270346da3fbbdd (patch) | |
tree | 35a8b0abaaddce5bd26f4c06a3bebbb19f014239 /tests/QtCore/qobject_property_test.py | |
parent | 1162a844bd689958205d10eeff549451ee8cb93b (diff) |
Raise a error when try to modify a read-only property.
Add get function as mandatory in QProperty constructor.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests/QtCore/qobject_property_test.py')
-rw-r--r-- | tests/QtCore/qobject_property_test.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/QtCore/qobject_property_test.py b/tests/QtCore/qobject_property_test.py index 233d1e8a1..7d53e0a26 100644 --- a/tests/QtCore/qobject_property_test.py +++ b/tests/QtCore/qobject_property_test.py @@ -16,6 +16,16 @@ class MySize(QSize): class ExtQObject(QObject): registeredproperty = QProperty(int) +class MyObject(QObject): + '''Test Property''' + + def readPP(self): + return 42 + + def trySetPP(self): + self.pp = 0 + + pp = QProperty(int, readPP) class PropertyCase(unittest.TestCase): '''Test case for QObject properties''' @@ -115,6 +125,11 @@ class PropertyWithConstructorCase(unittest.TestCase): obj = QTimer(objectName='dummy') self.assertEqual(obj.objectName(), 'dummy') + def testPythonProperty(self): + o = MyObject() + self.assertEqual(o.pp, 42) + o.pp = 0 + self.assertRaises(AttributeError, o.trySetPP) if __name__ == '__main__': unittest.main() |