# -*- Mode: Python -*-

import unittest

from gi.repository import GObject
import testhelper


GUnknown = GObject.type_from_name("TestUnknown")
Unknown = GUnknown.pytype


class MyUnknown(Unknown, testhelper.Interface):
    some_property = GObject.Property(type=str)

    def __init__(self):
        Unknown.__init__(self)
        self.called = False

    def do_iface_method(self):
        self.called = True
        Unknown.do_iface_method(self)
GObject.type_register(MyUnknown)


class MyObject(GObject.GObject, testhelper.Interface):
    some_property = GObject.Property(type=str)

    def __init__(self):
        GObject.GObject.__init__(self)
        self.called = False

    def do_iface_method(self):
        self.called = True
GObject.type_register(MyObject)


class TestIfaceImpl(unittest.TestCase):

    def testReImplementInterface(self):
        m = MyUnknown()
        m.iface_method()
        self.assertEqual(m.called, True)

    def testImplementInterface(self):
        m = MyObject()
        m.iface_method()
        self.assertEqual(m.called, True)

@@ -68,16 +68,25 @@
 GObject%0A
+try:%0A    
 import t
@@ -95,16 +95,58 @@
 thelper%0A
+except ImportError:%0A    testhelper = None%0A
 %0A%0AGUnkno
@@ -216,16 +216,105 @@
 ytype%0A%0A%0A
+class TestIfaceImpl(unittest.TestCase):%0A%0A    def testReImplementInterface(self):%0A        
 class My
@@ -345,32 +345,40 @@
 per.Interface):%0A
+        
     some_propert
@@ -401,32 +401,40 @@
 erty(type=str)%0A%0A
+        
     def __init__
@@ -433,32 +433,40 @@
 __init__(self):%0A
+        
         Unknown.
@@ -480,32 +480,40 @@
 _(self)%0A        
+ 
+       
 self.called = Fa
@@ -509,32 +509,40 @@
 called = False%0A%0A
+        
     def do_iface
@@ -556,32 +556,40 @@
 (self):%0A        
+   
+     
 self.called = Tr
@@ -591,32 +591,40 @@
  = True%0A        
+   
+     
 Unknown.do_iface
@@ -637,16 +637,24 @@
 d(self)%0A
+        
 GObject.
@@ -679,17 +679,153 @@
 known)%0A%0A
-%0A
+        m = MyUnknown()%0A        m.iface_method()%0A        self.assertEqual(m.called, True)%0A%0A    def testImplementInterface(self):%0A        
 class My
@@ -867,24 +867,32 @@
 Interface):%0A
+        
     some_pro
@@ -923,24 +923,32 @@
 (type=str)%0A%0A
+        
     def __in
@@ -951,32 +951,40 @@
 __init__(self):%0A
+        
         GObject.
@@ -1006,32 +1006,40 @@
 _(self)%0A        
+ 
+       
 self.called = Fa
@@ -1039,24 +1039,32 @@
 ed = False%0A%0A
+        
     def do_i
@@ -1082,32 +1082,40 @@
 (self):%0A        
+   
+     
 self.called = Tr
@@ -1117,16 +1117,24 @@
  = True%0A
+        
 GObject.
@@ -1161,220 +1161,8 @@
 ct)%0A
-%0A%0Aclass TestIfaceImpl(unittest.TestCase):%0A%0A    def testReImplementInterface(self):%0A        m = MyUnknown()%0A        m.iface_method()%0A        self.assertEqual(m.called, True)%0A%0A    def testImplementInterface(self):%0A
     

Make it possible to import test_interface without testhelper