MCPcopy Index your code
hub / github.com/python/cpython / test_stdin_stdout

Method test_stdin_stdout

Lib/test/test_asyncio/test_subprocess.py:148–172  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

146class SubprocessMixin:
147
148 def test_stdin_stdout(self):
149 args = PROGRAM_CAT
150
151 async def run(data):
152 proc = await asyncio.create_subprocess_exec(
153 *args,
154 stdin=subprocess.PIPE,
155 stdout=subprocess.PIPE,
156 )
157
158 # feed data
159 proc.stdin.write(data)
160 await proc.stdin.drain()
161 proc.stdin.close()
162
163 # get output and exitcode
164 data = await proc.stdout.read()
165 exitcode = await proc.wait()
166 return (exitcode, data)
167
168 task = run(b'some data')
169 task = asyncio.wait_for(task, 60.0)
170 exitcode, stdout = self.loop.run_until_complete(task)
171 self.assertEqual(exitcode, 0)
172 self.assertEqual(stdout, b'some data')
173
174 def test_communicate(self):
175 args = PROGRAM_CAT

Callers

nothing calls this directly

Calls 4

runFunction · 0.50
wait_forMethod · 0.45
run_until_completeMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected