Commit 35ca2ddd authored by Yury Selivanov's avatar Yury Selivanov

asyncio: Increase asyncio.Future test coverage; test both implementations.

Also, add 'isfuture' to 'asyncio.futures.__all__', so that it's
exposed as 'asyncio.isfuture'.
parent af21ba6c
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
__all__ = ['CancelledError', 'TimeoutError', __all__ = ['CancelledError', 'TimeoutError',
'InvalidStateError', 'InvalidStateError',
'Future', 'wrap_future', 'Future', 'wrap_future', 'isfuture'
] ]
import concurrent.futures._base import concurrent.futures._base
...@@ -389,6 +389,10 @@ class Future: ...@@ -389,6 +389,10 @@ class Future:
__await__ = __iter__ # make compatible with 'await' expression __await__ = __iter__ # make compatible with 'await' expression
# Needed for testing purposes.
_PyFuture = Future
def _set_result_unless_cancelled(fut, result): def _set_result_unless_cancelled(fut, result):
"""Helper setting the result only if the future was not cancelled.""" """Helper setting the result only if the future was not cancelled."""
if fut.cancelled(): if fut.cancelled():
...@@ -488,4 +492,5 @@ try: ...@@ -488,4 +492,5 @@ try:
except ImportError: except ImportError:
pass pass
else: else:
Future = _asyncio.Future # _CFuture is needed for tests.
Future = _CFuture = _asyncio.Future
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment