pygobject r739 - in trunk: . gio tests



Author: johan
Date: Sun Jan 20 10:07:26 2008
New Revision: 739
URL: http://svn.gnome.org/viewvc/pygobject?rev=739&view=rev

Log:
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.



Modified:
   trunk/ChangeLog
   trunk/gio/gio.override
   trunk/tests/test_gio.py

Modified: trunk/gio/gio.override
==============================================================================
--- trunk/gio/gio.override	(original)
+++ trunk/gio/gio.override	Sun Jan 20 10:07:26 2008
@@ -300,7 +300,9 @@
       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;

Modified: trunk/tests/test_gio.py
==============================================================================
--- trunk/tests/test_gio.py	(original)
+++ trunk/tests/test_gio.py	Sun Jan 20 10:07:26 2008
@@ -23,7 +23,9 @@
 
     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 @@
         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):



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