diff options
author | Simon Feltman <sfeltman@src.gnome.org> | 2013-07-28 14:44:51 -0700 |
---|---|---|
committer | Simon Feltman <sfeltman@src.gnome.org> | 2013-09-26 04:20:37 -0700 |
commit | 510789d52e9e2fd863d26613f3282364eb175601 (patch) | |
tree | 6c5d440d304304761fc99369ae08c261fb9c002b /tests/test_everything.py | |
parent | 03f531ffb1adde0c48e98f92bd92f79416654fbe (diff) | |
download | pygobject-510789d52e9e2fd863d26613f3282364eb175601.tar.gz |
Add support for default arguments annotated with allow-none
Support default value of NULL for tail end arguments which are
marked with allow-none.
The implementation uses a place holder object for un-supplied arguments
which are annotated with allow-none. This is then used later during
marshaling to supply NULL as the default.
Additionally support an implicit default for callback user_data
using the same technique.
https://bugzilla.gnome.org/show_bug.cgi?id=640812
Diffstat (limited to 'tests/test_everything.py')
-rw-r--r-- | tests/test_everything.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_everything.py b/tests/test_everything.py index b2f05288..0c6533a8 100644 --- a/tests/test_everything.py +++ b/tests/test_everything.py @@ -717,6 +717,22 @@ class TestCallbacks(unittest.TestCase): self.assertEqual(TestCallbacks.called, 100) + def test_callback_userdata_none_default_arg(self): + TestCallbacks.called = 0 + userdata_list = [] + + def callback(userdata): + userdata_list.append(userdata) + TestCallbacks.called += 1 + return TestCallbacks.called + + for i in range(100): + val = Everything.test_callback_user_data(callback) + self.assertEqual(val, i + 1) + + self.assertEqual(TestCallbacks.called, 100) + self.assertSequenceEqual(userdata_list, [None] * 100) + def test_async_ready_callback(self): TestCallbacks.called = False TestCallbacks.main_loop = GLib.MainLoop() |