[Python-checkins] cpython (3.4): Issue #22685: Debug test_pause_reading() on FreeBSD

victor.stinner python-checkins at python.org
Fri Nov 28 18:03:20 CET 2014


https://hg.python.org/cpython/rev/737355f61ba2
changeset:   93647:737355f61ba2
branch:      3.4
parent:      93645:8224253ef4b7
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri Nov 28 18:02:03 2014 +0100
summary:
  Issue #22685: Debug test_pause_reading() on FreeBSD

files:
  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
--- a/Lib/test/test_asyncio/test_subprocess.py
+++ b/Lib/test/test_asyncio/test_subprocess.py
@@ -163,13 +163,14 @@
         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 @@
             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':

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list