From a4c52fb9728cb889cefd9fed025fbac87a69dc70 Mon Sep 17 00:00:00 2001 From: Arthur Darcet Date: Fri, 24 Nov 2017 11:06:17 +0100 Subject: [PATCH] test multiple waiting drains in PayloadWriter --- tests/test_http_writer.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_http_writer.py b/tests/test_http_writer.py index ac5280fc391..3530abcc7e8 100644 --- a/tests/test_http_writer.py +++ b/tests/test_http_writer.py @@ -1,5 +1,6 @@ """Tests for aiohttp/http_writer.py""" +import asyncio import zlib from unittest import mock @@ -148,3 +149,19 @@ def test_write_drain(stream, loop): msg.write(b'1', drain=True) assert msg.drain.called assert msg.buffer_size == 0 + + +async def test_multiple_drains(stream, loop): + stream.available = False + msg = http.PayloadWriter(stream, loop) + fut1 = loop.create_task(msg.drain()) + fut2 = loop.create_task(msg.drain()) + + assert not fut1.done() + assert not fut2.done() + + msg.set_transport(stream.transport) + + await asyncio.sleep(0) + assert fut1.done() + assert fut2.done()