diff options
author | Renato Filho <renato.filho@openbossa.org> | 2011-07-22 18:19:47 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:54:39 -0300 |
commit | 238222df8e3a2a5f00652ba47361cb6d9d1e0a16 (patch) | |
tree | c2054315232517991482b9003c3d8e8ed498026c /tests | |
parent | dffc9a21ead22af64143b6f3d568505b36333f9d (diff) |
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.txt | 1 | ||||
-rw-r--r-- | tests/QtCore/qproperty_decorator.py | 35 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index c5147e8c6..9900a85c0 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 000000000..404ce2400 --- /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() |