diff options
author | Johan Dahlin <johan@src.gnome.org> | 2005-07-08 15:00:54 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2005-07-08 15:00:54 +0000 |
commit | 264ff959e8c3925ecb0b9756c1b6f807ef7115aa (patch) | |
tree | 2c008174de4c24c405de5aa2bf983115b35a76ac /tests | |
parent | 6a1807bcce49bf88eb786a78478e7780801c7a36 (diff) | |
download | pygobject-264ff959e8c3925ecb0b9756c1b6f807ef7115aa.tar.gz |
And unittest..
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_properties.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/test_properties.py b/tests/test_properties.py new file mode 100644 index 00000000..db620eae --- /dev/null +++ b/tests/test_properties.py @@ -0,0 +1,54 @@ + +import unittest + +from common import testhelper +from gobject import GObject, GType, PARAM_READWRITE + +class PropertyObject(GObject): + __gproperties__ = { + 'property': (str, 'blurb', 'description', + 'default', + PARAM_READWRITE), + } + def __init__(self): + GObject.__init__(self) + self._value = 'default' + + def do_get_property(self, pspec): + if pspec.name != 'property': + raise AssertionError + return self._value + + def do_set_property(self, pspec, value): + if pspec.name != 'property': + raise AssertionError + self._value = value + +class TestProperties(unittest.TestCase): + def testGetSet(self): + obj = PropertyObject() + obj.props.property = "value" + self.assertEqual(obj.props.property, "value") + + def testListWithInstance(self): + obj = PropertyObject() + self.failUnless(hasattr(obj.props, "property")) + + def testListWithoutInstance(self): + self.failUnless(hasattr(PropertyObject.props, "property")) + + def testSetNoInstance(self): + def set(obj): + obj.props.property = "foobar" + + self.assertRaises(TypeError, set, PropertyObject) + + def testIterator(self): + for obj in (PropertyObject.props, PropertyObject().props): + for pspec in obj: + gtype = GType(pspec) + self.assertEqual(gtype.parent.name, 'GParam') + self.assertEqual(pspec.name, 'property') + + self.assertEqual(len(obj), 1) + self.assertEqual(list(obj), [pspec]) |