Skip to content

Commit

Permalink
Add a regression test for large stderr reading
Browse files Browse the repository at this point in the history
Regression test for
#363
  • Loading branch information
lovasoa authored and fantix committed Feb 5, 2021
1 parent fcb3735 commit 68db1a2
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,34 @@ async def test_subprocess():

loop.run_until_complete(test_subprocess())

def test_communicate_large_stdout_65536(self):
self._test_communicate_large_stdout(65536)

def test_communicate_large_stdout_65537(self):
self._test_communicate_large_stdout(65537)

def test_communicate_large_stdout_1000000(self):
self._test_communicate_large_stdout(1000000)

def _test_communicate_large_stdout(self, size):
async def copy_stdin_to_stdout(stdin):
# See https://github.com/MagicStack/uvloop/issues/363
# A program that copies stdin to stdout character by character
code = ('import sys, shutil; '
'shutil.copyfileobj(sys.stdin, sys.stdout, 1)')
proc = await asyncio.create_subprocess_exec(
sys.executable, b'-W', b'ignore', b'-c', code,
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE)
stdout, _stderr = await asyncio.wait_for(proc.communicate(stdin),
60.0)
return stdout

stdin = b'x' * size
stdout = self.loop.run_until_complete(copy_stdin_to_stdout(stdin))
self.assertEqual(stdout, stdin)

def test_write_huge_stdin_8192(self):
self._test_write_huge_stdin(8192)

Expand Down

0 comments on commit 68db1a2

Please sign in to comment.