Commit 52b82c5f authored by Martin Pitt's avatar Martin Pitt
Browse files

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)
parent c7aa0e79
......@@ -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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment