diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-08-12 14:44:36 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-08-13 18:38:31 -0300 |
commit | 9a19bd26d2282743aae939c0497a9bc2d92ee8d9 (patch) | |
tree | c35fd8905d214b1e95ca762e2b8f6538f6af8c88 /tests/QtCore/qobject_property_test.py | |
parent | 2b21d79f5439d982de2495d3a190c4f82f51e458 (diff) |
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>
Diffstat (limited to 'tests/QtCore/qobject_property_test.py')
-rw-r--r-- | tests/QtCore/qobject_property_test.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/QtCore/qobject_property_test.py b/tests/QtCore/qobject_property_test.py index e94562c90..233d1e8a1 100644 --- a/tests/QtCore/qobject_property_test.py +++ b/tests/QtCore/qobject_property_test.py @@ -13,6 +13,10 @@ class MySize(QSize): '''Extended class''' pass +class ExtQObject(QObject): + registeredproperty = QProperty(int) + + class PropertyCase(unittest.TestCase): '''Test case for QObject properties''' @@ -91,5 +95,27 @@ 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.''' + + 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__': unittest.main() + |