We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d7c96e2 commit 68c63faCopy full SHA for 68c63fa
tests/test_utils.py
@@ -0,0 +1,18 @@
1
+from channels.utils import await_many_dispatch
2
+import asyncio
3
+import async_timeout
4
+from unittest import mock
5
+import pytest
6
+
7
8
+async def sleep_task(*args):
9
+ await asyncio.sleep(10)
10
11
12
+@pytest.mark.asyncio
13
+async def test_cancel_callback_called():
14
+ cancel_callback = mock.AsyncMock()
15
+ with pytest.raises(asyncio.TimeoutError):
16
+ async with async_timeout.timeout(0):
17
+ await await_many_dispatch([sleep_task], sleep_task, cancel_callback)
18
+ assert cancel_callback.called
0 commit comments