@@ -163,13 +163,14 @@ def test_communicate_ignore_broken_pipe(self):
163
163
self .loop .run_until_complete (proc .wait ())
164
164
165
165
def test_pause_reading (self ):
166
+ limit = 10
167
+ size = (limit * 2 + 1 )
168
+
166
169
@asyncio .coroutine
167
170
def test_pause_reading ():
168
- limit = 100
169
-
170
171
code = '\n ' .join ((
171
172
'import sys' ,
172
- 'sys.stdout.write("x" * %s)' % ( limit * 2 + 1 ) ,
173
+ 'sys.stdout.write("x" * %s)' % size ,
173
174
'sys.stdout.flush()' ,
174
175
))
175
176
proc = yield from asyncio .create_subprocess_exec (
@@ -181,17 +182,19 @@ def test_pause_reading():
181
182
stdout_transport = proc ._transport .get_pipe_transport (1 )
182
183
stdout_transport .pause_reading = mock .Mock ()
183
184
184
- yield from proc .wait ()
185
+ stdout , stderr = yield from proc .communicate ()
185
186
186
187
# The child process produced more than limit bytes of output,
187
188
# the stream reader transport should pause the protocol to not
188
189
# allocate too much memory.
189
- return stdout_transport . pause_reading . called
190
+ return ( stdout , stdout_transport )
190
191
191
192
# Issue #22685: Ensure that the stream reader pauses the protocol
192
193
# when the child process produces too much data
193
- called = self .loop .run_until_complete (test_pause_reading ())
194
- self .assertTrue (called )
194
+ stdout , transport = self .loop .run_until_complete (test_pause_reading ())
195
+
196
+ self .assertEqual (stdout , b'x' * size )
197
+ self .assertTrue (transport .pause_reading .called )
195
198
196
199
197
200
if sys .platform != 'win32' :
0 commit comments