-
-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
847f735
commit 70a4cfc
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import asyncio | ||
from unittest import mock | ||
|
||
import async_timeout | ||
import pytest | ||
|
||
from channels.utils import await_many_dispatch | ||
|
||
|
||
async def sleep_task(*args): | ||
await asyncio.sleep(10) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_cancel_callback_called(): | ||
cancel_callback = mock.AsyncMock() | ||
with pytest.raises(asyncio.TimeoutError): | ||
async with async_timeout.timeout(0): | ||
await await_many_dispatch([sleep_task], sleep_task, cancel_callback) | ||
assert cancel_callback.called |