summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-07-22 18:19:47 -0300
committerRenato Filho <renato.filho@openbossa.org>2011-07-25 11:29:22 -0300
commitaf629d13fc63808f2f9fcdb64a6f7a6bf24dbc0e (patch)
tree3a7cf52d9e9cc1f55f27085b2f0a3156ade4c341 /tests
parent5644a87c28c6e82346f057a5c8b524c40a7e94e4 (diff)
downloadpyside-af629d13fc63808f2f9fcdb64a6f7a6bf24dbc0e.tar.gz
pyside-af629d13fc63808f2f9fcdb64a6f7a6bf24dbc0e.tar.xz
pyside-af629d13fc63808f2f9fcdb64a6f7a6bf24dbc0e.zip
Created unit test for property decorator.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Lauro Neto <lauro.neto@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/QtCore/CMakeLists.txt1
-rw-r--r--tests/QtCore/qproperty_decorator.py35
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt
index c5147e8..9900a85 100644
--- a/tests/QtCore/CMakeLists.txt
+++ b/tests/QtCore/CMakeLists.txt
@@ -73,6 +73,7 @@ PYSIDE_TEST(qobject_timer_event_test.py)
PYSIDE_TEST(qobject_tr_as_instance_test.py)
PYSIDE_TEST(qpoint_test.py)
PYSIDE_TEST(qprocess_test.py)
+PYSIDE_TEST(qproperty_decorator.py)
PYSIDE_TEST(qrect_test.py)
PYSIDE_TEST(qregexp_test.py)
PYSIDE_TEST(qresource_test.py)
diff --git a/tests/QtCore/qproperty_decorator.py b/tests/QtCore/qproperty_decorator.py
new file mode 100644
index 0000000..404ce24
--- /dev/null
+++ b/tests/QtCore/qproperty_decorator.py
@@ -0,0 +1,35 @@
+import weakref
+import unittest
+
+from PySide.QtCore import QObject, Property
+
+class MyObject(QObject):
+ def __init__(self):
+ QObject.__init__(self)
+ self._value = None
+
+ @Property(int)
+ def value(self):
+ return self._value
+
+ @value.setter
+ def valueSet(self, value):
+ self._value = value
+
+
+class PropertyTest(unittest.TestCase):
+ def destroyCB(self, obj):
+ self._obDestroyed = True
+
+ def testDecorator(self):
+ self._obDestroyed = False
+ o = MyObject()
+ weak = weakref.ref(o, self.destroyCB)
+ o.value = 10
+ self.assertEqual(o._value, 10)
+ self.assertEqual(o.value, 10)
+ del o
+ self.assertTrue(self._obDestroyed)
+
+if __name__ == '__main__':
+ unittest.main()