diff options
author | Ignacio Casal Quinteiro <icq@gnome.org> | 2011-10-10 11:24:42 +0200 |
---|---|---|
committer | Ignacio Casal Quinteiro <icq@gnome.org> | 2011-10-10 11:24:42 +0200 |
commit | bef8d385117dd0295c9ba7567710d76fc2bb729a (patch) | |
tree | 2e6bb76dcbf1b7a9ce60507ae006376a3ee51dfc | |
parent | 77123ffeb1585837033848f4d5a90cfa63fdaee0 (diff) | |
download | pygobject-bef8d385117dd0295c9ba7567710d76fc2bb729a.tar.gz |
Add tests for boxed properties.
-rw-r--r-- | tests/test_properties.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/test_properties.py b/tests/test_properties.py index d02dac9b..35216479 100644 --- a/tests/test_properties.py +++ b/tests/test_properties.py @@ -15,6 +15,7 @@ from gi.repository.GObject import \ G_MAXULONG from gi.repository import Gio +from gi.repository import GLib if sys.version_info < (3, 0): TEST_UTF8 = "\xe2\x99\xa5" @@ -39,6 +40,9 @@ class PropertyObject(GObject.GObject): enum = GObject.property( type=Gio.SocketType, default=Gio.SocketType.STREAM) + boxed = GObject.property( + type=GLib.Regex, flags=PARAM_READWRITE|PARAM_CONSTRUCT) + class TestProperties(unittest.TestCase): def testGetSet(self): obj = PropertyObject() @@ -67,8 +71,9 @@ class TestProperties(unittest.TestCase): 'construct', 'construct-only', 'uint64', - 'enum']) - self.assertEqual(len(obj), 5) + 'enum', + 'boxed']) + self.assertEqual(len(obj), 6) def testNormal(self): obj = new(PropertyObject, normal="123") @@ -161,6 +166,17 @@ class TestProperties(unittest.TestCase): self.assertRaises(TypeError, GObject.property, type=Gio.SocketType, default=1) + def textBoxed(self): + obj = new(PropertyObject) + + regex = GLib.Regex.new('[a-z]*', 0, 0) + obj.props.boxed = regex + self.assertEqual(obj.props.boxed.get_pattern(), '[a-z]*') + self.assertEqual(obj.boxed.get_patttern(), '[a-z]*') + + self.assertRaises(TypeError, setattr, obj, 'boxed', 'foo') + self.assertRaises(TypeError, setattr, obj, 'boxed', object()) + def testRange(self): # kiwi code def max(c): |