summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohan Dahlin <johan@src.gnome.org>2006-04-29 18:49:45 +0000
committerJohan Dahlin <johan@src.gnome.org>2006-04-29 18:49:45 +0000
commit96a9e4a5b55cde0cc1b13a583dbb28b14fbce46c (patch)
treed7e27e251da05d9ae7df89a52fc9308000c68007 /tests
parentc9fe8615db8d42e4da9bc83525f6167291cbb217 (diff)
downloadpygobject-96a9e4a5b55cde0cc1b13a583dbb28b14fbce46c.tar.gz
Fix #154845, add tests and a private method.
* gobject/pygtype.c (gclosure_from_pyfunc): * gobject/pygobject.c (pygobject_disconnect_by_func) (pygobject_handler_block_by_func) (pygobject_handler_unblock_by_func): * tests/test_signal.py (TestEmissionHook._callback): Fix #154845, add tests and a private method.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_signal.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_signal.py b/tests/test_signal.py
index f006fae1..6cf93135 100644
--- a/tests/test_signal.py
+++ b/tests/test_signal.py
@@ -168,5 +168,34 @@ class TestEmissionHook(unittest.TestCase):
self.assertEqual(e.status, 1)
e.status = 3
+class TestClosures(unittest.TestCase):
+ def setUp(self):
+ self.count = 0
+
+ def _callback(self, e):
+ self.count += 1
+
+ def testDisconnect(self):
+ e = E()
+ e.connect('signal', self._callback)
+ e.disconnect_by_func(self._callback)
+ e.emit('signal')
+ self.assertEqual(self.count, 0)
+
+ def testHandlerBlock(self):
+ e = E()
+ e.connect('signal', self._callback)
+ e.handler_block_by_func(self._callback)
+ e.emit('signal')
+ self.assertEqual(self.count, 0)
+
+ def testHandlerUnBlock(self):
+ e = E()
+ signal_id = e.connect('signal', self._callback)
+ e.handler_block(signal_id)
+ e.handler_unblock_by_func(self._callback)
+ e.emit('signal')
+ self.assertEqual(self.count, 1)
+
if __name__ == '__main__':
unittest.main()