-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically create task for events
- Loading branch information
Showing
3 changed files
with
33 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import asyncio | ||
|
||
import pytest | ||
|
||
|
||
def test_events_default_task(docker): | ||
docker.events.subscribe() | ||
assert docker.events.task is not None | ||
docker.loop.run_until_complete(docker.events.stop()) | ||
assert docker.events.task.done() | ||
assert docker.events.json_stream is None | ||
|
||
|
||
def test_events_provided_task(docker): | ||
task = docker.loop.create_task(docker.events.run()) | ||
docker.events.subscribe(create_task=False) | ||
assert docker.events.task is None | ||
docker.loop.run_until_complete(docker.events.stop()) | ||
assert docker.events.json_stream is None | ||
task.cancel() | ||
with pytest.raises(asyncio.CancelledError): | ||
docker.loop.run_until_complete(task) |
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