diff options
author | Johan Dahlin <johan@gnome.org> | 2008-01-20 10:07:26 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2008-01-20 10:07:26 +0000 |
commit | 7df645aa2537b31b7801206d4ea4125799ddd99c (patch) | |
tree | 2f480f066ef09d5909589d96e8f0c73e747025e2 | |
parent | e6d7181ababaa9f08602c48e03d6557ddb6a4deb (diff) | |
download | pygobject-7df645aa2537b31b7801206d4ea4125799ddd99c.tar.gz pygobject-7df645aa2537b31b7801206d4ea4125799ddd99c.tar.xz pygobject-7df645aa2537b31b7801206d4ea4125799ddd99c.zip |
New function to test error condition of async read.
2008-01-20 Johan Dahlin <johan@gnome.org>
* tests/test_gio.py (TestInputStream.testReadAsyncError):
New function to test error condition of async read.
* gio/gio.override (async_result_callback_marshal): Grab a reference
to callback/data.
svn path=/trunk/; revision=739
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | gio/gio.override | 4 | ||||
-rw-r--r-- | tests/test_gio.py | 21 |
3 files changed, 31 insertions, 2 deletions
@@ -1,3 +1,11 @@ +2008-01-20 Johan Dahlin <johan@gnome.org> + + * tests/test_gio.py (TestInputStream.testReadAsyncError): + New function to test error condition of async read. + + * gio/gio.override (async_result_callback_marshal): Grab a reference + to callback/data. + 2008-01-19 Johan Dahlin <johan@gnome.org> * gio/gio.override (_wrap_g_output_stream_write): Impl. diff --git a/gio/gio.override b/gio/gio.override index f6df13a..e2b8e50 100644 --- a/gio/gio.override +++ b/gio/gio.override @@ -300,7 +300,9 @@ _wrap_g_input_stream_read_async(PyGObject *self, PyObject *args, PyObject *kwarg g_slice_free(PyGAsyncRequestNotify, notify); return NULL; } - + Py_INCREF(notify->callback); + Py_XINCREF(notify->data); + buffer = PyString_FromStringAndSize((char *)NULL, count); if (buffer == NULL) return NULL; diff --git a/tests/test_gio.py b/tests/test_gio.py index fb41e51..3bb2746 100644 --- a/tests/test_gio.py +++ b/tests/test_gio.py @@ -23,7 +23,9 @@ class TestInputStream(unittest.TestCase): def testReadAsync(self): def callback(stream, result): - self.assertEquals(stream.read_finish(result), len("testing")) + read = stream.read_finish(result) + self.assertEquals(read, len("testing")) + stream.close() loop.quit() self.stream.read_async(10240, 0, None, callback) @@ -31,6 +33,23 @@ class TestInputStream(unittest.TestCase): loop = gobject.MainLoop() loop.run() + def testReadAsyncError(self): + self.count = 0 + def callback(stream, result): + self.count += 1 + if self.count == 1: + return + self.assertRaises(gobject.GError, stream.read_finish, result) + loop.quit() + + self.stream.read_async(10240, 0, None, callback) + self.stream.read_async(10240, 0, None, callback) + + loop = gobject.MainLoop() + loop.run() + + self.assertEquals(self.count, 2) + class TestOutputStream(unittest.TestCase): def setUp(self): |