tests: don't test for specific device labels
[pygobject.git] / tests / test_interface.py
blobca1e0f47c7bae6e9da41e6c7bc65ad262766d94c
1 # -*- Mode: Python -*-
3 from __future__ import absolute_import
5 import unittest
7 from gi.repository import GObject
8 import testhelper
11 GUnknown = GObject.type_from_name("TestUnknown")
12 Unknown = GUnknown.pytype
15 class MyUnknown(Unknown, testhelper.Interface):
16 some_property = GObject.Property(type=str)
18 def __init__(self):
19 Unknown.__init__(self)
20 self.called = False
22 def do_iface_method(self):
23 self.called = True
24 Unknown.do_iface_method(self)
27 GObject.type_register(MyUnknown)
30 class MyObject(GObject.GObject, testhelper.Interface):
31 some_property = GObject.Property(type=str)
33 def __init__(self):
34 GObject.GObject.__init__(self)
35 self.called = False
37 def do_iface_method(self):
38 self.called = True
41 GObject.type_register(MyObject)
44 class TestIfaceImpl(unittest.TestCase):
46 def test_reimplement_interface(self):
47 m = MyUnknown()
48 m.iface_method()
49 self.assertEqual(m.called, True)
51 def test_implement_interface(self):
52 m = MyObject()
53 m.iface_method()
54 self.assertEqual(m.called, True)