[pygobject] test_gi: Check setting properties in constructor



commit 6af74c501bc604559f8b5b4e0d856d022ed882bb
Author: Martin Pitt <martinpitt gnome org>
Date:   Sun May 6 06:02:31 2012 -0700

    test_gi: Check setting properties in constructor

 tests/test_gi.py |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 90a002e..0c67623 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -1987,6 +1987,9 @@ class TestPropertiesObject(unittest.TestCase):
         self.obj.props.some_boolean = True
         self.assertEqual(self.obj.props.some_boolean, True)
 
+        obj = GIMarshallingTests.PropertiesObject(some_boolean=True)
+        self.assertEqual(obj.props.some_boolean, True)
+
     @unittest.expectedFailure
     def test_char(self):
         # gobject-introspection thinks it has a guint8 type tag, which is
@@ -1999,51 +2002,81 @@ class TestPropertiesObject(unittest.TestCase):
 
         GLib.log_set_always_fatal(old_mask)
 
+        obj = GIMarshallingTests.PropertiesObject(some_char=-42)
+        self.assertEqual(obj.props.some_char, -42)
+
     def test_uchar(self):
         self.assertEqual(self.obj.props.some_uchar, 0)
         self.obj.props.some_uchar = GObject.G_MAXUINT8
         self.assertEqual(self.obj.props.some_uchar, GObject.G_MAXUINT8)
 
+        obj = GIMarshallingTests.PropertiesObject(some_uchar=42)
+        self.assertEqual(obj.props.some_uchar, 42)
+
     def test_int(self):
         self.assertEqual(self.obj.props.some_int, 0)
         self.obj.props.some_int = GObject.G_MAXINT
         self.assertEqual(self.obj.props.some_int, GObject.G_MAXINT)
 
+        obj = GIMarshallingTests.PropertiesObject(some_int=-42)
+        self.assertEqual(obj.props.some_int, -42)
+
     def test_uint(self):
         self.assertEqual(self.obj.props.some_uint, 0)
         self.obj.props.some_uint = GObject.G_MAXUINT
         self.assertEqual(self.obj.props.some_uint, GObject.G_MAXUINT)
 
+        obj = GIMarshallingTests.PropertiesObject(some_uint=42)
+        self.assertEqual(obj.props.some_uint, 42)
+
     def test_long(self):
         self.assertEqual(self.obj.props.some_long, 0)
         self.obj.props.some_long = GObject.G_MAXLONG
         self.assertEqual(self.obj.props.some_long, GObject.G_MAXLONG)
 
+        obj = GIMarshallingTests.PropertiesObject(some_long=-42)
+        self.assertEqual(obj.props.some_long, -42)
+
     def test_ulong(self):
         self.assertEqual(self.obj.props.some_ulong, 0)
         self.obj.props.some_ulong = GObject.G_MAXULONG
         self.assertEqual(self.obj.props.some_ulong, GObject.G_MAXULONG)
 
+        obj = GIMarshallingTests.PropertiesObject(some_ulong=42)
+        self.assertEqual(obj.props.some_ulong, 42)
+
     def test_int64(self):
         self.assertEqual(self.obj.props.some_int64, 0)
         self.obj.props.some_int64 = GObject.G_MAXINT64
         self.assertEqual(self.obj.props.some_int64, GObject.G_MAXINT64)
 
+        obj = GIMarshallingTests.PropertiesObject(some_int64=-4200000000000000)
+        self.assertEqual(obj.props.some_int64, -4200000000000000)
+
     def test_uint64(self):
         self.assertEqual(self.obj.props.some_uint64, 0)
         self.obj.props.some_uint64 = GObject.G_MAXUINT64
         self.assertEqual(self.obj.props.some_uint64, GObject.G_MAXUINT64)
 
+        obj = GIMarshallingTests.PropertiesObject(some_uint64=4200000000000000)
+        self.assertEqual(obj.props.some_uint64, 4200000000000000)
+
     def test_float(self):
         self.assertEqual(self.obj.props.some_float, 0)
         self.obj.props.some_float = GObject.G_MAXFLOAT
         self.assertEqual(self.obj.props.some_float, GObject.G_MAXFLOAT)
 
+        obj = GIMarshallingTests.PropertiesObject(some_float=42.42)
+        self.assertAlmostEqual(obj.props.some_float, 42.42, 4)
+
     def test_double(self):
         self.assertEqual(self.obj.props.some_double, 0)
         self.obj.props.some_double = GObject.G_MAXDOUBLE
         self.assertEqual(self.obj.props.some_double, GObject.G_MAXDOUBLE)
 
+        obj = GIMarshallingTests.PropertiesObject(some_double=42.42)
+        self.assertAlmostEqual(obj.props.some_double, 42.42)
+
     def test_strv(self):
         self.assertEqual(self.obj.props.some_strv, [])
         self.obj.props.some_strv = ['hello', 'world']



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