Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test case for #7859 #7866

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ Jeongkyu Shin
Jeroen van der Heijden
Jesus Cea
Jian Zeng
Jing Yan
Jinkyu Yi
Joel Watts
John Parton
Expand Down
23 changes: 23 additions & 0 deletions tests/test_websocket_writer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# type: ignore
import asyncio
import random
from typing import Any
from unittest import mock
Expand Down Expand Up @@ -106,3 +107,25 @@ async def test_send_compress_text_per_message(protocol: Any, transport: Any) ->
writer.transport.write.assert_called_with(b"\x81\x04text")
await writer.send(b"text", compress=15)
writer.transport.write.assert_called_with(b"\xc1\x06*I\xad(\x01\x00")


@pytest.mark.xfail(raises=AssertionError, reason="#7859")
async def test_send_compress_text_with_async_executor_parallel(
protocol: Any, transport: Any
) -> None:
writer = WebSocketWriter(protocol, transport, compress=15)
# send 10 messages in parallel
await asyncio.gather(*(writer.send(b"b" * (5 * 1024 + 1)) for _ in range(10)))
assert (
writer.transport.write.call_args_list[0][0][0]
== b"\xc1)\xec\xd0\x81\x10\x00\x00\x00\x03!\xd7\xf7\x87\x98\xc7\xae\x10*\x0c"
b"\x180`\xc0\x80\x01\x03\x06\x0c\x180`\xc0\x80\x01\x03\x06\x0c\x18\xb8\x1d"
b"\x18\x00"
)
for result in writer.transport.write.call_args_list[1:]:
assert (
result[0][0]
== b"\xc1&\xec\xd0\x81\x0c\x00\x00\x00\xc0 \x7f\xeb{|\x85\x10\x06\x0c"
b"\x180`\xc0\x80\x01\x03\x06\x0c\x180`\xc0\x80\x01\x03\x06\x0c\x8c"
b"\x07\x02"
Comment on lines +121 to +130
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than depending on the compressed bytes, which is rather hard to evaluate, can we test that reading/decompressing gives the expected output?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think bdraco has already got this covered actually: https://github.com/aio-libs/aiohttp/pull/7865/files#diff-c82db6bac3cc2b13785c62de3180bef31a0dc1046cdc7655ca7d873d6c220eb4R114

So, we can probably close this one.

)