-
-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support async actions * Fixes after main rebase * Test is_coroutine_callable
- Loading branch information
Showing
3 changed files
with
97 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import functools | ||
|
||
from tenacity import _utils | ||
|
||
|
||
def test_is_coroutine_callable() -> None: | ||
async def async_func() -> None: | ||
pass | ||
|
||
def sync_func() -> None: | ||
pass | ||
|
||
class AsyncClass: | ||
async def __call__(self) -> None: | ||
pass | ||
|
||
class SyncClass: | ||
def __call__(self) -> None: | ||
pass | ||
|
||
lambda_fn = lambda: None # noqa: E731 | ||
|
||
partial_async_func = functools.partial(async_func) | ||
partial_sync_func = functools.partial(sync_func) | ||
partial_async_class = functools.partial(AsyncClass().__call__) | ||
partial_sync_class = functools.partial(SyncClass().__call__) | ||
partial_lambda_fn = functools.partial(lambda_fn) | ||
|
||
assert _utils.is_coroutine_callable(async_func) is True | ||
assert _utils.is_coroutine_callable(sync_func) is False | ||
assert _utils.is_coroutine_callable(AsyncClass) is False | ||
assert _utils.is_coroutine_callable(AsyncClass()) is True | ||
assert _utils.is_coroutine_callable(SyncClass) is False | ||
assert _utils.is_coroutine_callable(SyncClass()) is False | ||
assert _utils.is_coroutine_callable(lambda_fn) is False | ||
|
||
assert _utils.is_coroutine_callable(partial_async_func) is True | ||
assert _utils.is_coroutine_callable(partial_sync_func) is False | ||
assert _utils.is_coroutine_callable(partial_async_class) is True | ||
assert _utils.is_coroutine_callable(partial_sync_class) is False | ||
assert _utils.is_coroutine_callable(partial_lambda_fn) is False |