We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d7c96e2 commit c691752Copy full SHA for c691752
tests/test_utils.py
@@ -0,0 +1,17 @@
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
+async def sleep_task(*args):
8
+ await asyncio.sleep(10)
9
10
+@pytest.mark.asyncio
11
+async def test_cancel_callback_called():
12
+ cancel_callback = mock.AsyncMock()
13
+ with pytest.raises(asyncio.TimeoutError):
14
+ async with async_timeout.timeout(0):
15
+ await await_many_dispatch([sleep_task], sleep_task, cancel_callback)
16
+ print(cancel_callback.__dict__)
17
+ assert cancel_callback.called
0 commit comments