[pygobject] Add test for a callback with an inout array
- From: Garrett Regier <gregier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Add test for a callback with an inout array
- Date: Thu, 7 Aug 2014 19:56:31 +0000 (UTC)
commit 59c257ebc47fa725750344dd50dd8eb522536d3c
Author: Garrett Regier <Garrett Regier riftio com>
Date: Thu Aug 7 12:25:59 2014 -0400
Add test for a callback with an inout array
This was broken until the closures used the caches for marshaling.
https://bugzilla.gnome.org/show_bug.cgi?id=702508
tests/test_everything.py | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/tests/test_everything.py b/tests/test_everything.py
index e753dcc..dfd1dc4 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -669,6 +669,25 @@ class TestCallbacks(unittest.TestCase):
[([-1, 0, 1, 2], ['one', 'two', 'three'])] * 2)
self.assertEqual(sys.getrefcount(callback), refcount)
+ @unittest.skipUnless(hasattr(Everything, 'test_array_inout_callback'),
+ 'Requires newer version of GI')
+ def test_callback_scope_call_array_inout(self):
+ # This tests a callback that gets called multiple times from a
+ # single scope call in python with inout array arguments
+ TestCallbacks.callargs = []
+
+ def callback(ints, ints_length):
+ TestCallbacks.callargs.append(ints)
+ return ints[1:], len(ints[1:])
+
+ refcount = sys.getrefcount(callback)
+ result = Everything.test_array_inout_callback(callback)
+ self.assertEqual(TestCallbacks.callargs,
+ [[-2, -1, 0, 1, 2], [-1, 0, 1, 2]])
+ # first callback should give 4, second 3
+ self.assertEqual(result, 3)
+ self.assertEqual(sys.getrefcount(callback), refcount)
+
def test_callback_userdata(self):
TestCallbacks.called = 0
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]