[pygobject] Add tests for calling closures
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Add tests for calling closures
- Date: Thu, 27 Oct 2011 05:20:27 +0000 (UTC)
commit 52b82c5f78ef3755388457fa9440c36ccd2dfbbf
Author: Martin Pitt <martin pitt ubuntu com>
Date: Thu Oct 27 07:16:24 2011 +0200
Add tests for calling closures
Add checks for correct handling of closure calls.
Regress.test_closure_one_arg() is working fine and should continue to do so.
Regress.test_closure_variant() is known to not work yet, so mark this as EXFAIL
for now. (See https://bugzilla.gnome.org/show_bug.cgi?id=656554)
tests/test_everything.py | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/tests/test_everything.py b/tests/test_everything.py
index 19d345b..43735e5 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -350,6 +350,30 @@ class TestCallbacks(unittest.TestCase):
# make sure this doesn't assert or crash
Everything.test_simple_callback(None)
+class TestClosures(unittest.TestCase):
+ def test_int_arg(self):
+ def callback(num):
+ self.called = True
+ return num+1
+
+ self.called = False
+ result = Everything.test_closure_one_arg(callback, 42)
+ self.assertTrue(self.called)
+ self.assertEqual(result, 43)
+
+ # https://bugzilla.gnome.org/show_bug.cgi?id=656554
+ @unittest.expectedFailure
+ def test_variant(self):
+ def callback(variant):
+ self.assertEqual(variant.get_type_string(), 'i')
+ self.called = True
+ return GLib.Variant('i', variant.get_int32() + 1)
+
+ self.called = False
+ result = Everything.test_closure_variant(callback, GLib.Variant('i', 42))
+ self.assertTrue(self.called)
+ self.assertEqual(result.get_type_string(), 'i')
+ self.assertEqual(result.get_int32(), 43)
class TestProperties(unittest.TestCase):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]