11import asyncio
22import contextlib
33import signal
4- import socket
54import subprocess
65import sys
76import tempfile
8- import uvloop
97
108from asyncio import test_utils
119from uvloop import _testbase as tb
12- from test import support
1310
1411
1512class _TestProcess :
@@ -276,12 +273,12 @@ def test_stdin_not_inheritable(self):
276273 def len_message (message ):
277274 code = 'import sys; data = sys.stdin.read(); print(len(data))'
278275 proc = yield from asyncio .create_subprocess_exec (
279- sys .executable , '-c' , code ,
280- stdin = asyncio .subprocess .PIPE ,
281- stdout = asyncio .subprocess .PIPE ,
282- stderr = asyncio .subprocess .PIPE ,
283- close_fds = False ,
284- loop = self .loop )
276+ sys .executable , '-c' , code ,
277+ stdin = asyncio .subprocess .PIPE ,
278+ stdout = asyncio .subprocess .PIPE ,
279+ stderr = asyncio .subprocess .PIPE ,
280+ close_fds = False ,
281+ loop = self .loop )
285282 stdout , stderr = yield from proc .communicate (message )
286283 exitcode = yield from proc .wait ()
287284 return (stdout , exitcode )
@@ -296,10 +293,10 @@ def test_stdin_stdout(self):
296293 @asyncio .coroutine
297294 def run (data ):
298295 proc = yield from asyncio .create_subprocess_exec (
299- * args ,
300- stdin = subprocess .PIPE ,
301- stdout = subprocess .PIPE ,
302- loop = self .loop )
296+ * args ,
297+ stdin = subprocess .PIPE ,
298+ stdout = subprocess .PIPE ,
299+ loop = self .loop )
303300
304301 # feed data
305302 proc .stdin .write (data )
@@ -323,10 +320,10 @@ def test_communicate(self):
323320 @asyncio .coroutine
324321 def run (data ):
325322 proc = yield from asyncio .create_subprocess_exec (
326- * args ,
327- stdin = subprocess .PIPE ,
328- stdout = subprocess .PIPE ,
329- loop = self .loop )
323+ * args ,
324+ stdin = subprocess .PIPE ,
325+ stdout = subprocess .PIPE ,
326+ loop = self .loop )
330327 stdout , stderr = yield from proc .communicate (data )
331328 return proc .returncode , stdout
332329
@@ -389,35 +386,14 @@ def send_signal(proc):
389386 returncode = self .loop .run_until_complete (send_signal (proc ))
390387 self .assertEqual (- signal .SIGHUP , returncode )
391388
392- def test_stdin_not_inheritable (self ):
393- # asyncio issue #209: stdin must not be inheritable, otherwise
394- # the Process.communicate() hangs
395- @asyncio .coroutine
396- def len_message (message ):
397- code = 'import sys; data = sys.stdin.read(); print(len(data))'
398- proc = yield from asyncio .create_subprocess_exec (
399- sys .executable , '-c' , code ,
400- stdin = asyncio .subprocess .PIPE ,
401- stdout = asyncio .subprocess .PIPE ,
402- stderr = asyncio .subprocess .PIPE ,
403- close_fds = False ,
404- loop = self .loop )
405- stdout , stderr = yield from proc .communicate (message )
406- exitcode = yield from proc .wait ()
407- return (stdout , exitcode )
408-
409- output , exitcode = self .loop .run_until_complete (len_message (b'abc' ))
410- self .assertEqual (output .rstrip (), b'3' )
411- self .assertEqual (exitcode , 0 )
412-
413389 def test_cancel_process_wait (self ):
414390 # Issue #23140: cancel Process.wait()
415391
416392 @asyncio .coroutine
417393 def cancel_wait ():
418394 proc = yield from asyncio .create_subprocess_exec (
419- * self .PROGRAM_BLOCKED ,
420- loop = self .loop )
395+ * self .PROGRAM_BLOCKED ,
396+ loop = self .loop )
421397
422398 # Create an internal future waiting on the process exit
423399 task = self .loop .create_task (proc .wait ())
0 commit comments