diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-11-28 18:02:03 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-11-28 18:02:03 +0100 |
commit | 440d1673ae5c5f7a646d5c9845b0128d028d1379 (patch) | |
tree | e5659eedbe758f62b14357d4fbc710a2f3464374 /Lib/test/test_asyncio/test_subprocess.py | |
parent | 9d65c68d8ad654eebf94c789cd152d5cc3df1afa (diff) | |
download | cpython-440d1673ae5c5f7a646d5c9845b0128d028d1379.tar.gz |
Issue #22685: Debug test_pause_reading() on FreeBSD
Diffstat (limited to 'Lib/test/test_asyncio/test_subprocess.py')
-rw-r--r-- | Lib/test/test_asyncio/test_subprocess.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py index d0ab23080d..c84078d32f 100644 --- a/Lib/test/test_asyncio/test_subprocess.py +++ b/Lib/test/test_asyncio/test_subprocess.py @@ -163,13 +163,14 @@ class SubprocessMixin: self.loop.run_until_complete(proc.wait()) def test_pause_reading(self): + limit = 10 + size = (limit * 2 + 1) + @asyncio.coroutine def test_pause_reading(): - limit = 100 - code = '\n'.join(( 'import sys', - 'sys.stdout.write("x" * %s)' % (limit * 2 + 1), + 'sys.stdout.write("x" * %s)' % size, 'sys.stdout.flush()', )) proc = yield from asyncio.create_subprocess_exec( @@ -181,17 +182,19 @@ class SubprocessMixin: stdout_transport = proc._transport.get_pipe_transport(1) stdout_transport.pause_reading = mock.Mock() - yield from proc.wait() + stdout, stderr = yield from proc.communicate() # The child process produced more than limit bytes of output, # the stream reader transport should pause the protocol to not # allocate too much memory. - return stdout_transport.pause_reading.called + return (stdout, stdout_transport) # Issue #22685: Ensure that the stream reader pauses the protocol # when the child process produces too much data - called = self.loop.run_until_complete(test_pause_reading()) - self.assertTrue(called) + stdout, transport = self.loop.run_until_complete(test_pause_reading()) + + self.assertEqual(stdout, b'x' * size) + self.assertTrue(transport.pause_reading.called) if sys.platform != 'win32': |