[pygobject/pygobject-3-8] tests: Add tests for overriding vfunc implementations



commit 02ae144067561f74e71bb7690d058de4852187bd
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 2671588..33a77ab 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -2074,6 +2074,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)
@@ -2147,6 +2150,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))
@@ -2288,6 +2295,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]