Skip to content

Commit

Permalink
test multiple waiting drains in PayloadWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurdarcet committed Nov 24, 2017
1 parent 0c6c30e commit a4c52fb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_http_writer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests for aiohttp/http_writer.py"""

import asyncio
import zlib
from unittest import mock

Expand Down Expand Up @@ -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()

0 comments on commit a4c52fb

Please sign in to comment.