diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2019-05-07 20:53:19 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-05-07 20:53:19 (GMT) |
commit | 1cc0ee7d9f6a2817918fafd24c18d8bb093a85d3 (patch) | |
tree | 03a2e1f32fb51d8fc1c8e8ce8ebd64f672de8709 /Lib/test/test_asyncio | |
parent | e19a91e45fd54a56e39c2d12e6aaf4757030507f (diff) | |
download | cpython-1cc0ee7d9f6a2817918fafd24c18d8bb093a85d3.zip cpython-1cc0ee7d9f6a2817918fafd24c18d8bb093a85d3.tar.gz cpython-1cc0ee7d9f6a2817918fafd24c18d8bb093a85d3.tar.bz2 |
bpo-36801: Fix waiting in StreamWriter.drain for closing SSL transport (GH-13098)
https://bugs.python.org/issue36801
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r-- | Lib/test/test_asyncio/test_streams.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py index c1cc9d7..905141c 100644 --- a/Lib/test/test_asyncio/test_streams.py +++ b/Lib/test/test_asyncio/test_streams.py @@ -109,6 +109,29 @@ class StreamTests(test_utils.TestCase): self._basetest_open_connection_no_loop_ssl(conn_fut) + @unittest.skipIf(ssl is None, 'No ssl module') + def test_drain_on_closed_writer_ssl(self): + + async def inner(httpd): + reader, writer = await asyncio.open_connection( + *httpd.address, + ssl=test_utils.dummy_ssl_context()) + + messages = [] + self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx)) + writer.write(b'GET / HTTP/1.0\r\n\r\n') + data = await reader.read() + self.assertTrue(data.endswith(b'\r\n\r\nTest message')) + + writer.close() + with self.assertRaises(ConnectionResetError): + await writer.drain() + + self.assertEqual(messages, []) + + with test_utils.run_test_server(use_ssl=True) as httpd: + self.loop.run_until_complete(inner(httpd)) + def _basetest_open_connection_error(self, open_connection_fut): messages = [] self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx)) |