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

Method test_async_writer_api

Lib/test/test_asyncio/test_streams.py:1062–1080  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1060 self.loop.run_until_complete(wr.wait_closed())
1061
1062 def test_async_writer_api(self):
1063 async def inner(httpd):
1064 rd, wr = await asyncio.open_connection(*httpd.address)
1065
1066 wr.write(b'GET / HTTP/1.0\r\n\r\n')
1067 data = await rd.readline()
1068 self.assertEqual(data, b'HTTP/1.0 200 OK\r\n')
1069 data = await rd.read()
1070 self.assertEndsWith(data, b'\r\n\r\nTest message')
1071 wr.close()
1072 await wr.wait_closed()
1073
1074 messages = []
1075 self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))
1076
1077 with test_utils.run_test_server() as httpd:
1078 self.loop.run_until_complete(inner(httpd))
1079
1080 self.assertEqual(messages, [])
1081
1082 def test_async_writer_api_exception_after_close(self):
1083 async def inner(httpd):

Callers

nothing calls this directly

Calls 5

innerFunction · 0.50
set_exception_handlerMethod · 0.45
appendMethod · 0.45
run_until_completeMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected