[pygobject] test_subprocess: Cover more child_watch_add() cases
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] test_subprocess: Cover more child_watch_add() cases
- Date: Sun, 28 Oct 2012 21:38:51 +0000 (UTC)
commit 4b16427714b850e33c6020d8de1833bae19a3b87
Author: Martin Pitt <martinpitt gnome org>
Date: Sun Oct 28 13:44:23 2012 +0100
test_subprocess: Cover more child_watch_add() cases
Verify that priority is set correctly, and also test calling without userdata.
tests/test_subprocess.py | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/tests/test_subprocess.py b/tests/test_subprocess.py
index 48e29e5..65d9eeb 100644
--- a/tests/test_subprocess.py
+++ b/tests/test_subprocess.py
@@ -8,18 +8,32 @@ from gi.repository import GLib
class TestProcess(unittest.TestCase):
- def _child_watch_cb(self, pid, condition, data):
- self.data = data
- self.loop.quit()
+ def test_child_watch_no_data(self):
+ def cb(pid, condition):
+ self.loop.quit()
+
+ self.loop = GLib.MainLoop()
+ argv = [sys.executable, '-c', 'import sys']
+ pid, stdin, stdout, stderr = GLib.spawn_async(
+ argv, flags=GLib.SpawnFlags.DO_NOT_REAP_CHILD)
+ pid.close()
+ GLib.child_watch_add(pid, cb)
+ self.loop.run()
+
+ def test_child_watch_data_priority(self):
+ def cb(pid, condition, data):
+ self.data = data
+ self.loop.quit()
- def test_child_watch(self):
self.data = None
self.loop = GLib.MainLoop()
argv = [sys.executable, '-c', 'import sys']
pid, stdin, stdout, stderr = GLib.spawn_async(
argv, flags=GLib.SpawnFlags.DO_NOT_REAP_CHILD)
pid.close()
- GLib.child_watch_add(pid, self._child_watch_cb, 12345)
+ id = GLib.child_watch_add(pid, cb, 12345, GLib.PRIORITY_HIGH)
+ self.assertEqual(self.loop.get_context().find_source_by_id(id).priority,
+ GLib.PRIORITY_HIGH)
self.loop.run()
self.assertEqual(self.data, 12345)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]