diff options
Diffstat (limited to 'tests/QtCore')
-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() + |