pygobject r766 - in trunk: . gobject tests



Author: johan
Date: Tue Apr  8 15:27:54 2008
New Revision: 766
URL: http://svn.gnome.org/viewvc/pygobject?rev=766&view=rev

Log:
2008-04-08  Johan Dahlin  <jdahlin async com br>

    * gobject/pygsource.c:
    * tests/test_source.py:
    Unbreak Source.prepare (#523075, Bryan Silverthorn)



Modified:
   trunk/ChangeLog
   trunk/gobject/pygsource.c
   trunk/tests/test_source.py

Modified: trunk/gobject/pygsource.c
==============================================================================
--- trunk/gobject/pygsource.c	(original)
+++ trunk/gobject/pygsource.c	Tue Apr  8 15:27:54 2008
@@ -418,14 +418,12 @@
     }
 
     ret = PyObject_IsTrue(PyTuple_GET_ITEM(t, 0));
-
-    if (ret) {
 	*timeout = PyInt_AsLong(PyTuple_GET_ITEM(t, 1));
+
 	if (*timeout == -1 && PyErr_Occurred()) {
 	    ret = FALSE;
 	    goto bail;
 	}
-    }
 
     got_err = FALSE;
 

Modified: trunk/tests/test_source.py
==============================================================================
--- trunk/tests/test_source.py	(original)
+++ trunk/tests/test_source.py	Tue Apr  8 15:27:54 2008
@@ -62,5 +62,33 @@
 
         assert self.pos >= 0 and idle.count >= 0
 
+    def testSourcePrepare(self):
+        # this test may not terminate if prepare() is wrapped incorrectly
+        dispatched = [False]
+        loop = gobject.MainLoop()
+
+        class CustomTimeout(gobject.Source):
+            def prepare(self):
+                return (False, 10)
+
+            def check(self):
+                return True
+
+            def dispatch(self, callback, args):
+                dispatched[0] = True
+
+                loop.quit()
+
+                return False
+
+        source = CustomTimeout()
+
+        source.attach()
+        source.set_callback(dir)
+
+        loop.run()
+
+        assert dispatched[0]
+
 if __name__ == '__main__':
     unittest.main()



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