1 |
commit: c3a1ace347c2f0b078a3c69343e32a65c853f883 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Sep 2 22:18:21 2013 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Sep 2 22:18:21 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c3a1ace3 |
7 |
|
8 |
PipeReaderTestCase: use PopenProcess |
9 |
|
10 |
--- |
11 |
pym/portage/tests/process/test_poll.py | 36 +++++++++++++++++----------------- |
12 |
1 file changed, 18 insertions(+), 18 deletions(-) |
13 |
|
14 |
diff --git a/pym/portage/tests/process/test_poll.py b/pym/portage/tests/process/test_poll.py |
15 |
index 3772d79..8c57c23 100644 |
16 |
--- a/pym/portage/tests/process/test_poll.py |
17 |
+++ b/pym/portage/tests/process/test_poll.py |
18 |
@@ -1,12 +1,14 @@ |
19 |
-# Copyright 1998-2011 Gentoo Foundation |
20 |
+# Copyright 1998-2013 Gentoo Foundation |
21 |
# Distributed under the terms of the GNU General Public License v2 |
22 |
|
23 |
+import subprocess |
24 |
+ |
25 |
from portage import os |
26 |
from portage.tests import TestCase |
27 |
from portage.util._pty import _create_pty_or_pipe |
28 |
-from portage.util._async.TaskScheduler import TaskScheduler |
29 |
+from portage.util._async.PopenProcess import PopenProcess |
30 |
+from portage.util._eventloop.global_event_loop import global_event_loop |
31 |
from _emerge.PipeReader import PipeReader |
32 |
-from _emerge.SpawnProcess import SpawnProcess |
33 |
|
34 |
class PipeReaderTestCase(TestCase): |
35 |
|
36 |
@@ -36,24 +38,22 @@ class PipeReaderTestCase(TestCase): |
37 |
# WARNING: It is very important to use unbuffered mode here, |
38 |
# in order to avoid issue 5380 with python3. |
39 |
master_file = os.fdopen(master_fd, 'rb', 0) |
40 |
- slave_file = os.fdopen(slave_fd, 'wb', 0) |
41 |
- producer = SpawnProcess( |
42 |
- args=["bash", "-c", self._echo_cmd % test_string], |
43 |
- env=os.environ, fd_pipes={1:slave_fd}) |
44 |
+ scheduler = global_event_loop() |
45 |
|
46 |
consumer = PipeReader( |
47 |
input_files={"producer" : master_file}, |
48 |
- _use_array=self._use_array) |
49 |
- |
50 |
- task_scheduler = TaskScheduler(iter([producer, consumer]), max_jobs=2) |
51 |
- |
52 |
- # This will ensure that both tasks have exited, which |
53 |
- # is necessary to avoid "ResourceWarning: unclosed file" |
54 |
- # warnings since Python 3.2 (and also ensures that we |
55 |
- # don't leave any zombie child processes). |
56 |
- task_scheduler.start() |
57 |
- slave_file.close() |
58 |
- task_scheduler.wait() |
59 |
+ _use_array=self._use_array, |
60 |
+ scheduler=scheduler) |
61 |
+ |
62 |
+ producer = PopenProcess( |
63 |
+ pipe_reader=consumer, |
64 |
+ proc=subprocess.Popen(["bash", "-c", self._echo_cmd % test_string], |
65 |
+ stdout=slave_fd), |
66 |
+ scheduler=scheduler) |
67 |
+ |
68 |
+ producer.start() |
69 |
+ os.close(slave_fd) |
70 |
+ producer.wait() |
71 |
|
72 |
self.assertEqual(producer.returncode, os.EX_OK) |
73 |
self.assertEqual(consumer.returncode, os.EX_OK) |