rendered paste body# -*- Mode: Python -*-import gcimport unittestimport sysimport popen2from common import gobjectclass TestProcess(unittest.TestCase): def _child_watch_cb(self, pid, condition, data): self.data = data self.loop.quit() def testChildWatch(self): self.data = None self.loop = gobject.MainLoop() argv = [sys.executable, '-c', 'import sys'] pid, stdin, stdout, stderr = gobject.spawn_async( argv, flags=gobject.SPAWN_DO_NOT_REAP_CHILD) gobject.child_watch_add(pid, self._child_watch_cb, 12345) self.loop.run() self.assertEqual(self.data, 12345) def testChildWatchPopen(self): self.data = None self.loop = gobject.MainLoop() #argv = [sys.executable, '-c', 'import sys'] argv = "sleep 3" p = popen2.Popen3 (argv) gobject.child_watch_add(p.pid, self._child_watch_cb, 12345) self.loop.run() self.assertEqual(self.data, 12345)if __name__ == '__main__': unittest.main()