[pygobject] Add tests for boxed properties.



commit bef8d385117dd0295c9ba7567710d76fc2bb729a
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Mon Oct 10 11:24:42 2011 +0200

    Add tests for boxed properties.

 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 d02dac9..3521647 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):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]