[pygobject] Add enum and flags member methods



commit 43b35b1df3b6c0d8679f3cc0b08ef6ddcb276331
Author: Simon Feltman <sfeltman src gnome org>
Date:   Mon Jan 6 17:35:04 2014 -0800

    Add enum and flags member methods
    
    Add all methods from GIEnumInfo to both enums and flags classes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=693099

 gi/module.py     |    2 ++
 tests/test_gi.py |    9 +++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/gi/module.py b/gi/module.py
index 71f8ac5..ae6f6e2 100644
--- a/gi/module.py
+++ b/gi/module.py
@@ -163,6 +163,8 @@ class IntrospectionModule(object):
                 for value_info in info.get_values():
                     value_name = value_info.get_name_unescaped().translate(ascii_upper_trans)
                     setattr(wrapper, value_name, wrapper(value_info.get_value()))
+                for method_info in info.get_methods():
+                    setattr(wrapper, method_info.__name__, method_info)
 
             if g_type != TYPE_NONE:
                 g_type.pytype = wrapper
diff --git a/tests/test_gi.py b/tests/test_gi.py
index f7a7bc6..2411a49 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -1555,6 +1555,7 @@ class TestGEnum(unittest.TestCase):
     def test_genum_in(self):
         GIMarshallingTests.genum_in(GIMarshallingTests.GEnum.VALUE3)
         GIMarshallingTests.genum_in(42)
+        GIMarshallingTests.GEnum.in_(42)
 
         self.assertRaises(TypeError, GIMarshallingTests.genum_in, 43)
         self.assertRaises(TypeError, GIMarshallingTests.genum_in, 'GIMarshallingTests.GEnum.VALUE3')
@@ -1566,6 +1567,7 @@ class TestGEnum(unittest.TestCase):
 
     def test_genum_out(self):
         genum = GIMarshallingTests.genum_out()
+        genum = GIMarshallingTests.GEnum.out()
         self.assertTrue(isinstance(genum, GIMarshallingTests.GEnum))
         self.assertEqual(genum, GIMarshallingTests.GEnum.VALUE3)
 
@@ -1598,9 +1600,11 @@ class TestGFlags(unittest.TestCase):
 
     def test_flags_in(self):
         GIMarshallingTests.flags_in(GIMarshallingTests.Flags.VALUE2)
+        GIMarshallingTests.Flags.in_(GIMarshallingTests.Flags.VALUE2)
         # result of __or__() operation should still be valid instance, not an int.
         GIMarshallingTests.flags_in(GIMarshallingTests.Flags.VALUE2 | GIMarshallingTests.Flags.VALUE2)
         GIMarshallingTests.flags_in_zero(Number(0))
+        GIMarshallingTests.Flags.in_zero(Number(0))
 
         self.assertRaises(TypeError, GIMarshallingTests.flags_in, 1 << 1)
         self.assertRaises(TypeError, GIMarshallingTests.flags_in, 'GIMarshallingTests.Flags.VALUE2')
@@ -1610,6 +1614,11 @@ class TestGFlags(unittest.TestCase):
         self.assertTrue(isinstance(flags, GIMarshallingTests.Flags))
         self.assertEqual(flags, GIMarshallingTests.Flags.VALUE2)
 
+    def test_flags_return_method(self):
+        flags = GIMarshallingTests.Flags.returnv()
+        self.assertTrue(isinstance(flags, GIMarshallingTests.Flags))
+        self.assertEqual(flags, GIMarshallingTests.Flags.VALUE2)
+
     def test_flags_out(self):
         flags = GIMarshallingTests.flags_out()
         self.assertTrue(isinstance(flags, GIMarshallingTests.Flags))


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