diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2018-09-13 16:53:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-13 16:53:49 -0700 |
commit | 11194c877c902a6c3b769d85be887c2272e0a541 (patch) | |
tree | 8181f75217256e9035a177cee53916e4fa6eacab /Lib/test/test_asyncio/test_streams.py | |
parent | 413118ebf3162418639a5c4af14b02d26571a02c (diff) | |
download | cpython-git-11194c877c902a6c3b769d85be887c2272e0a541.tar.gz |
bpo-34666: Implement stream.awrite() and stream.aclose() (GH-9274)
Diffstat (limited to 'Lib/test/test_asyncio/test_streams.py')
-rw-r--r-- | Lib/test/test_asyncio/test_streams.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py index 67ac9d91a0..d8e371510d 100644 --- a/Lib/test/test_asyncio/test_streams.py +++ b/Lib/test/test_asyncio/test_streams.py @@ -964,6 +964,28 @@ os.close(fd) 'call "stream.close()" explicitly.', messages[0]['message']) + def test_async_writer_api(self): + messages = [] + self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx)) + + with test_utils.run_test_server() as httpd: + rd, wr = self.loop.run_until_complete( + asyncio.open_connection(*httpd.address, + loop=self.loop)) + + f = wr.awrite(b'GET / HTTP/1.0\r\n\r\n') + self.loop.run_until_complete(f) + f = rd.readline() + data = self.loop.run_until_complete(f) + self.assertEqual(data, b'HTTP/1.0 200 OK\r\n') + f = rd.read() + data = self.loop.run_until_complete(f) + self.assertTrue(data.endswith(b'\r\n\r\nTest message')) + f = wr.aclose() + self.loop.run_until_complete(f) + + self.assertEqual(messages, []) + if __name__ == '__main__': unittest.main() |