[pygobject] Add test for callback user data arguments with following arguments



commit a50a8386aae54dace7e46569415fdef85758fb9c
Author: Martin Pitt <martinpitt gnome org>
Date:   Tue Jan 14 08:53:25 2014 +0100

    Add test for callback user data arguments with following arguments
    
    In this case we can't use the varargs userdata handling. Provides test case for
    https://bugzilla.gnome.org/show_bug.cgi?id=722104.

 tests/test_everything.py |   48 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/tests/test_everything.py b/tests/test_everything.py
index 61b40e1..5e58fbc 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -761,6 +761,54 @@ class TestCallbacks(unittest.TestCase):
         self.assertEqual(TestCallbacks.called, 10)
         self.assertSequenceEqual(collected_user_data, [1, 2] * 10)
 
+    def test_callback_user_data_middle_none(self):
+        cb_info = {}
+
+        def callback(userdata):
+            cb_info['called'] = True
+            cb_info['userdata'] = userdata
+            return 1
+
+        (y, z, q) = Everything.test_torture_signature_2(
+            42, callback, None, 'some string', 3)
+        self.assertEqual(y, 42)
+        self.assertEqual(z, 84)
+        self.assertEqual(q, 14)
+        self.assertTrue(cb_info['called'])
+        self.assertEqual(cb_info['userdata'], None)
+
+    def test_callback_user_data_middle_single(self):
+        cb_info = {}
+
+        def callback(userdata):
+            cb_info['called'] = True
+            cb_info['userdata'] = userdata
+            return 1
+
+        (y, z, q) = Everything.test_torture_signature_2(
+            42, callback, 'User Data', 'some string', 3)
+        self.assertEqual(y, 42)
+        self.assertEqual(z, 84)
+        self.assertEqual(q, 14)
+        self.assertTrue(cb_info['called'])
+        self.assertEqual(cb_info['userdata'], 'User Data')
+
+    def test_callback_user_data_middle_tuple(self):
+        cb_info = {}
+
+        def callback(userdata):
+            cb_info['called'] = True
+            cb_info['userdata'] = userdata
+            return 1
+
+        (y, z, q) = Everything.test_torture_signature_2(
+            42, callback, (-5, 'User Data'), 'some string', 3)
+        self.assertEqual(y, 42)
+        self.assertEqual(z, 84)
+        self.assertEqual(q, 14)
+        self.assertTrue(cb_info['called'])
+        self.assertEqual(cb_info['userdata'], (-5, 'User Data'))
+
     def test_async_ready_callback(self):
         TestCallbacks.called = False
         TestCallbacks.main_loop = GLib.MainLoop()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]