async def test_body_stream_single_chunk() -> None: body = Body(None, None) body.append(b"data") body.set_complete() async def _check_data() -> None: async for data in body: assert data == b"data" await asyncio.wait_for(_check_data(), 1)
async def _fill_body(body: Body, semaphore: asyncio.Semaphore, limit: int) -> None: for number in range(limit): body.append(b"%d" % number) await semaphore.acquire() body.set_complete()