Created unit test for property decorator.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>
Lauro Neto <lauro.neto@openbossa.org>
This commit is contained in:
parent
5644a87c28
commit
af629d13fc
2 changed files with 36 additions and 0 deletions
|
|
@ -73,6 +73,7 @@ PYSIDE_TEST(qobject_timer_event_test.py)
|
||||||
PYSIDE_TEST(qobject_tr_as_instance_test.py)
|
PYSIDE_TEST(qobject_tr_as_instance_test.py)
|
||||||
PYSIDE_TEST(qpoint_test.py)
|
PYSIDE_TEST(qpoint_test.py)
|
||||||
PYSIDE_TEST(qprocess_test.py)
|
PYSIDE_TEST(qprocess_test.py)
|
||||||
|
PYSIDE_TEST(qproperty_decorator.py)
|
||||||
PYSIDE_TEST(qrect_test.py)
|
PYSIDE_TEST(qrect_test.py)
|
||||||
PYSIDE_TEST(qregexp_test.py)
|
PYSIDE_TEST(qregexp_test.py)
|
||||||
PYSIDE_TEST(qresource_test.py)
|
PYSIDE_TEST(qresource_test.py)
|
||||||
|
|
|
||||||
35
tests/QtCore/qproperty_decorator.py
Normal file
35
tests/QtCore/qproperty_decorator.py
Normal file
|
|
@ -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()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue