summaryrefslogtreecommitdiffstats
path: root/tests/test_signal.py
diff options
context:
space:
mode:
authorJohan Dahlin <johan@src.gnome.org>2004-09-25 17:29:17 +0000
committerJohan Dahlin <johan@src.gnome.org>2004-09-25 17:29:17 +0000
commit98e8f5d07b21abe3b89667124858db5bc607e7c9 (patch)
tree4d1e709deff07c41b0dbea2a41372b1ced102798 /tests/test_signal.py
parentc67547acbb1d2e2355b0eae659e879df981c9eb3 (diff)
downloadpygobject-98e8f5d07b21abe3b89667124858db5bc607e7c9.tar.gz
pygobject-98e8f5d07b21abe3b89667124858db5bc607e7c9.tar.xz
pygobject-98e8f5d07b21abe3b89667124858db5bc607e7c9.zip
Move some tests from gtype and rename from signal.py
* tests/test_signal.py: Move some tests from gtype and rename from signal.py
Diffstat (limited to 'tests/test_signal.py')
-rw-r--r--tests/test_signal.py75
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/test_signal.py b/tests/test_signal.py
new file mode 100644
index 0000000..b4a6cdc
--- /dev/null
+++ b/tests/test_signal.py
@@ -0,0 +1,75 @@
+# -*- Mode: Python -*-
+
+import gc
+import unittest
+
+from common import gobject
+
+class C(gobject.GObject):
+ __gsignals__ = { 'my_signal': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ (gobject.TYPE_INT,)) }
+ def do_my_signal(self, arg):
+ self.arg = arg
+gobject.type_register(C)
+
+class D(C):
+ def do_my_signal(self, arg2):
+ self.arg2 = arg2
+ C.do_my_signal(self, arg2)
+gobject.type_register(D)
+
+class TestChaining(unittest.TestCase):
+ def setUp(self):
+ self.inst = C()
+ self.inst.connect("my_signal", self.my_signal_handler_cb, 1, 2, 3)
+
+ def my_signal_handler_cb(self, *args):
+ assert len(args) == 5
+ assert isinstance(args[0], C)
+ assert args[0] == self.inst
+
+ assert isinstance(args[1], int)
+ assert args[1] == 42
+
+ assert args[2:] == (1, 2, 3)
+
+ def testChaining(self):
+ self.inst.emit("my_signal", 42)
+ assert self.inst.arg == 42
+
+ def testChaining(self):
+ inst2 = D()
+ inst2.emit("my_signal", 44)
+ assert inst2.arg == 44
+ assert inst2.arg2 == 44
+
+# This is for bug 153718
+class TestGSignalsError(unittest.TestCase):
+ def testInvalidType(self, *args):
+ class Foo(gobject.GObject):
+ __gsignals__ = None
+ self.assertRaises(TypeError, gobject.type_register, Foo)
+ gc.collect()
+
+ def testInvalidName(self, *args):
+ class Foo(gobject.GObject):
+ __gsignals__ = {'not-exists' : 'override'}
+ self.assertRaises(TypeError, gobject.type_register, Foo)
+ gc.collect()
+
+class TestGPropertyError(unittest.TestCase):
+ def testInvalidType(self, *args):
+ class Foo(gobject.GObject):
+ __gproperties__ = None
+ self.assertRaises(TypeError, gobject.type_register, Foo)
+ gc.collect()
+
+ def testInvalidName(self, *args):
+ class Foo(gobject.GObject):
+ __gproperties__ = { None: None }
+
+ self.assertRaises(TypeError, gobject.type_register, Foo)
+ gc.collect()
+
+if __name__ == '__main__':
+ unittest.main()