summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2016-05-13 19:35:28 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2016-05-13 19:35:28 (GMT)
commit7657f6ba218aa59ee085f2001dc44247f2fd0d4c (patch)
tree0982bab9284b9c1eff4e30b991e1a2feb0757ffa /Lib/test/test_asyncio
parentd76c7c2bed3a6a3e840323647488ebf984914e4f (diff)
downloadcpython-7657f6ba218aa59ee085f2001dc44247f2fd0d4c.zip
cpython-7657f6ba218aa59ee085f2001dc44247f2fd0d4c.tar.gz
cpython-7657f6ba218aa59ee085f2001dc44247f2fd0d4c.tar.bz2
Issue #26848: Fix asyncio/subprocess.communicate() to handle empty input.
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r--Lib/test/test_asyncio/test_subprocess.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py
index e90f17d..4803826 100644
--- a/Lib/test/test_asyncio/test_subprocess.py
+++ b/Lib/test/test_asyncio/test_subprocess.py
@@ -287,6 +287,25 @@ class SubprocessMixin:
self.assertEqual(output.rstrip(), b'3')
self.assertEqual(exitcode, 0)
+ def test_empty_input(self):
+ @asyncio.coroutine
+ def empty_input():
+ code = 'import sys; data = sys.stdin.read(); print(len(data))'
+ proc = yield from asyncio.create_subprocess_exec(
+ sys.executable, '-c', code,
+ stdin=asyncio.subprocess.PIPE,
+ stdout=asyncio.subprocess.PIPE,
+ stderr=asyncio.subprocess.PIPE,
+ close_fds=False,
+ loop=self.loop)
+ stdout, stderr = yield from proc.communicate(b'')
+ exitcode = yield from proc.wait()
+ return (stdout, exitcode)
+
+ output, exitcode = self.loop.run_until_complete(empty_input())
+ self.assertEqual(output.rstrip(), b'0')
+ self.assertEqual(exitcode, 0)
+
def test_cancel_process_wait(self):
# Issue #23140: cancel Process.wait()