|View source on GitHub|
Gives the given future a chance to complete, and determines if it didn't.
cirq.testing.asyncio_pending( future: Union[Awaitable, asyncio.Future, Coroutine], timeout: float = 0.001 ) -> Awaitable[bool]
This method is used in tests checking that a future actually depends on some given event having happened. The test can assert, before the event, that the future is still pending and then assert, after the event, that the future has a result.
||The future that may or may not be able to resolve when given a bit of time.|
||The number of seconds to wait for the future. This should generally be a small value (milliseconds) when expecting the future to not resolve, and a large value (seconds) when expecting the future to resolve.|
|True if the future is still pending after the timeout elapses. False if the future did complete (or fail) or was already completed (or already failed).|
async def test_completion_only_when_expected():
f = asyncio.Future()
assert await cirq.testing.asyncio_pending(f)
assert await f == 5