1 |
commit: 0c96d2d0b18036cb94d68c42783441d32af2d9d3 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed May 9 07:54:26 2018 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed May 9 07:59:56 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=0c96d2d0 |
7 |
|
8 |
SubprocessExecTestCase: fix unintended skipTest |
9 |
|
10 |
The internal asyncio shim does not provide a |
11 |
create_subprocess_exec attribute, so access it |
12 |
directly from the real asyncio module. |
13 |
|
14 |
Fixes 82a3cda6f1ff ("Minimize _asyncio_wrapper usage (bug 654390)") |
15 |
|
16 |
.../util/futures/asyncio/test_subprocess_exec.py | 21 +++++++++++++-------- |
17 |
1 file changed, 13 insertions(+), 8 deletions(-) |
18 |
|
19 |
diff --git a/pym/portage/tests/util/futures/asyncio/test_subprocess_exec.py b/pym/portage/tests/util/futures/asyncio/test_subprocess_exec.py |
20 |
index 534d79c53..5a812ba6a 100644 |
21 |
--- a/pym/portage/tests/util/futures/asyncio/test_subprocess_exec.py |
22 |
+++ b/pym/portage/tests/util/futures/asyncio/test_subprocess_exec.py |
23 |
@@ -4,6 +4,11 @@ |
24 |
import os |
25 |
import subprocess |
26 |
|
27 |
+try: |
28 |
+ from asyncio import create_subprocess_exec |
29 |
+except ImportError: |
30 |
+ create_subprocess_exec = None |
31 |
+ |
32 |
from portage.process import find_binary |
33 |
from portage.tests import TestCase |
34 |
from portage.util._eventloop.global_event_loop import global_event_loop |
35 |
@@ -71,7 +76,7 @@ class SubprocessExecTestCase(TestCase): |
36 |
self.assertFalse(global_event_loop().is_closed()) |
37 |
|
38 |
def testEcho(self): |
39 |
- if not hasattr(asyncio, 'create_subprocess_exec'): |
40 |
+ if create_subprocess_exec is None: |
41 |
self.skipTest('create_subprocess_exec not implemented for python2') |
42 |
|
43 |
args_tuple = (b'hello', b'world') |
44 |
@@ -91,7 +96,7 @@ class SubprocessExecTestCase(TestCase): |
45 |
try: |
46 |
with open(os.devnull, 'rb', 0) as devnull: |
47 |
proc = loop.run_until_complete( |
48 |
- asyncio.create_subprocess_exec( |
49 |
+ create_subprocess_exec( |
50 |
echo_binary, *args_tuple, |
51 |
stdin=devnull, stdout=stdout_pw, stderr=stdout_pw)) |
52 |
|
53 |
@@ -114,7 +119,7 @@ class SubprocessExecTestCase(TestCase): |
54 |
self._run_test(test) |
55 |
|
56 |
def testCat(self): |
57 |
- if not hasattr(asyncio, 'create_subprocess_exec'): |
58 |
+ if create_subprocess_exec is None: |
59 |
self.skipTest('create_subprocess_exec not implemented for python2') |
60 |
|
61 |
stdin_data = b'hello world' |
62 |
@@ -138,7 +143,7 @@ class SubprocessExecTestCase(TestCase): |
63 |
output = None |
64 |
try: |
65 |
proc = loop.run_until_complete( |
66 |
- asyncio.create_subprocess_exec( |
67 |
+ create_subprocess_exec( |
68 |
cat_binary, |
69 |
stdin=stdin_pr, stdout=stdout_pw, stderr=stdout_pw)) |
70 |
|
71 |
@@ -173,7 +178,7 @@ class SubprocessExecTestCase(TestCase): |
72 |
requires an AbstractEventLoop.connect_read_pipe implementation |
73 |
(and a ReadTransport implementation for it to return). |
74 |
""" |
75 |
- if not hasattr(asyncio, 'create_subprocess_exec'): |
76 |
+ if create_subprocess_exec is None: |
77 |
self.skipTest('create_subprocess_exec not implemented for python2') |
78 |
|
79 |
args_tuple = (b'hello', b'world') |
80 |
@@ -184,7 +189,7 @@ class SubprocessExecTestCase(TestCase): |
81 |
def test(loop): |
82 |
with open(os.devnull, 'rb', 0) as devnull: |
83 |
proc = loop.run_until_complete( |
84 |
- asyncio.create_subprocess_exec( |
85 |
+ create_subprocess_exec( |
86 |
echo_binary, *args_tuple, |
87 |
stdin=devnull, |
88 |
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) |
89 |
@@ -202,7 +207,7 @@ class SubprocessExecTestCase(TestCase): |
90 |
requires an AbstractEventLoop.connect_write_pipe implementation |
91 |
(and a WriteTransport implementation for it to return). |
92 |
""" |
93 |
- if not hasattr(asyncio, 'create_subprocess_exec'): |
94 |
+ if create_subprocess_exec is None: |
95 |
self.skipTest('create_subprocess_exec not implemented for python2') |
96 |
|
97 |
stdin_data = b'hello world' |
98 |
@@ -212,7 +217,7 @@ class SubprocessExecTestCase(TestCase): |
99 |
|
100 |
def test(loop): |
101 |
proc = loop.run_until_complete( |
102 |
- asyncio.create_subprocess_exec( |
103 |
+ create_subprocess_exec( |
104 |
cat_binary, |
105 |
stdin=subprocess.PIPE, |
106 |
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) |