[pygobject] tests: Add tests for overriding vfunc implementations



commit 065503d5e284dc89bacd79d0d9a72eb739882bf8
Author: Simon Feltman <sfeltman src gnome org>
Date:   Sat May 11 21:47:54 2013 -0700

    tests: Add tests for overriding vfunc implementations
    
    Add tests for overriding vfuncs for both single inheritance
    and multiple inheritance with an interface (currently failing).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=700092

 tests/test_gi.py |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 2f5e8cf..47f0926 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -2056,6 +2056,9 @@ class TestPythonGObject(unittest.TestCase):
         def do_method_with_default_implementation(self, int8):
             self.val = int8
 
+        def do_vfunc_return_value_only(self):
+            return 2121
+
     class Interface3Impl(GObject.Object, GIMarshallingTests.Interface3):
         def __init__(self):
             GObject.Object.__init__(self)
@@ -2129,6 +2132,10 @@ class TestPythonGObject(unittest.TestCase):
         object_.method_with_default_implementation(87)
         self.assertEqual(object_.val, 87)
 
+    def test_subobject_child_vfunc(self):
+        object_ = self.SubObject(int=1)
+        self.assertEqual(object_.vfunc_return_value_only(), 2121)
+
     def test_dynamic_module(self):
         from gi.module import DynamicModule
         self.assertTrue(isinstance(GObject, DynamicModule))
@@ -2270,6 +2277,22 @@ class TestInterfaces(unittest.TestCase):
         GIMarshallingTests.test_interface_test_int8_in(instance, 42)
         self.assertEqual(instance.val, 42)
 
+    @unittest.expectedFailure  # https://bugzilla.gnome.org/show_bug.cgi?id=700092
+    def test_subclass_override(self):
+        class TestInterfaceImplD(TestInterfaces.TestInterfaceImpl):
+            val2 = None
+
+            def do_test_int8_in(self, int8):
+                self.val2 = int8
+
+        instance = TestInterfaceImplD()
+        self.assertEqual(instance.val, None)
+        self.assertEqual(instance.val2, None)
+
+        GIMarshallingTests.test_interface_test_int8_in(instance, 42)
+        self.assertEqual(instance.val, None)
+        self.assertEqual(instance.val2, 42)
+
     def test_mro(self):
         # there was a problem with Python bailing out because of
         # http://en.wikipedia.org/wiki/Diamond_problem with interfaces,


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