-
-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor common testing helpers into a separate module
- Loading branch information
1 parent
5541dda
commit 7208ec0
Showing
6 changed files
with
23 additions
and
93 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,18 @@ | ||
import asyncio | ||
from unittest import mock | ||
|
||
|
||
def AsyncMock(*args, **kwargs): | ||
"""Return a mock asynchronous function.""" | ||
m = mock.MagicMock(*args, **kwargs) | ||
|
||
async def mock_coro(*args, **kwargs): | ||
return m(*args, **kwargs) | ||
|
||
mock_coro.mock = m | ||
return mock_coro | ||
|
||
|
||
def _run(coro): | ||
"""Run the given coroutine.""" | ||
return asyncio.get_event_loop().run_until_complete(coro) |
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
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
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
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
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