diff options
author | Simon Feltman <sfeltman@src.gnome.org> | 2014-01-06 17:35:04 -0800 |
---|---|---|
committer | Simon Feltman <sfeltman@src.gnome.org> | 2014-01-06 17:35:04 -0800 |
commit | 43b35b1df3b6c0d8679f3cc0b08ef6ddcb276331 (patch) | |
tree | 8fdc487e768cbc5eeb9507d7336e74e06d7aeb2e | |
parent | 731a2cb4372084eac6cfe5bf190f6efa730e97e4 (diff) | |
download | pygobject-43b35b1df3b6c0d8679f3cc0b08ef6ddcb276331.tar.gz |
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
-rw-r--r-- | gi/module.py | 2 | ||||
-rw-r--r-- | tests/test_gi.py | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/gi/module.py b/gi/module.py index 71f8ac57..ae6f6e2d 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 f7a7bc6a..2411a49d 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)) |