summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_subprocess.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-12-21 10:24:19 (GMT)
committerGitHub <noreply@github.com>2022-12-21 10:24:19 (GMT)
commitae8520c70992710903819f24dbce4e7dd05d7ea8 (patch)
treea5f2c0f104947b9d49fe9992e19739327aacef30 /Lib/test/test_asyncio/test_subprocess.py
parentbed1d141a95e8d69f522e6f4e46e0647c68a2460 (diff)
downloadcpython-ae8520c70992710903819f24dbce4e7dd05d7ea8.zip
cpython-ae8520c70992710903819f24dbce4e7dd05d7ea8.tar.gz
cpython-ae8520c70992710903819f24dbce4e7dd05d7ea8.tar.bz2
GH-100133: fix `asyncio` subprocess losing `stderr` and `stdout` output (GH-100154)
(cherry picked from commit a7715ccfba5b86ab09f86ec56ac3755c93b46b48) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_asyncio/test_subprocess.py')
-rw-r--r--Lib/test/test_asyncio/test_subprocess.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py
index f71ad72..bea2314 100644
--- a/Lib/test/test_asyncio/test_subprocess.py
+++ b/Lib/test/test_asyncio/test_subprocess.py
@@ -684,6 +684,23 @@ class SubprocessMixin:
self.assertIsNone(self.loop.run_until_complete(execute()))
+ def test_subprocess_communicate_stdout(self):
+ # See https://github.com/python/cpython/issues/100133
+ async def get_command_stdout(cmd, *args):
+ proc = await asyncio.create_subprocess_exec(
+ cmd, *args, stdout=asyncio.subprocess.PIPE,
+ )
+ stdout, _ = await proc.communicate()
+ return stdout.decode().strip()
+
+ async def main():
+ outputs = [f'foo{i}' for i in range(10)]
+ res = await asyncio.gather(*[get_command_stdout(sys.executable, '-c',
+ f'print({out!r})') for out in outputs])
+ self.assertEqual(res, outputs)
+
+ self.loop.run_until_complete(main())
+
if sys.platform != 'win32':
# Unix