From 407a7630b75744da2366b955cea7c6b67a60c374 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Tue, 29 May 2018 16:55:23 -0400 Subject: [PATCH 1/2] A better fix for asyncio test_stdin_broken_pipe --- Lib/test/test_asyncio/test_subprocess.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py index 235813aa977c1e..afe26865695258 100644 --- a/Lib/test/test_asyncio/test_subprocess.py +++ b/Lib/test/test_asyncio/test_subprocess.py @@ -1,5 +1,7 @@ +import os import signal import sys +import time import unittest import warnings from unittest import mock @@ -218,8 +220,10 @@ def prepare_broken_pipe_test(self): # the program ends before the stdin can be feeded create = asyncio.create_subprocess_exec( - sys.executable, '-c', 'pass', + sys.executable, + '-c', 'print("hello", flush=True)', stdin=subprocess.PIPE, + stdout=subprocess.PIPE, loop=self.loop) proc = self.loop.run_until_complete(create) return (proc, large_data) @@ -228,7 +232,7 @@ def test_stdin_broken_pipe(self): proc, large_data = self.prepare_broken_pipe_test() async def write_stdin(proc, data): - await asyncio.sleep(0.5, loop=self.loop) + await proc.stdout.readline() proc.stdin.write(data) await proc.stdin.drain() From ce3d1625eb46d251b734c28cef92a53e1cab4eb0 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Tue, 29 May 2018 17:32:38 -0400 Subject: [PATCH 2/2] Drop unused imports --- Lib/test/test_asyncio/test_subprocess.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py index afe26865695258..01583376e5716b 100644 --- a/Lib/test/test_asyncio/test_subprocess.py +++ b/Lib/test/test_asyncio/test_subprocess.py @@ -1,7 +1,5 @@ -import os import signal import sys -import time import unittest import warnings from unittest import mock