Skip to content

Commit

Permalink
Fix py3.10 compatibility issue
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Nov 30, 2021
1 parent ca31c2d commit cce2af1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
registry: ['1']
pytest-arg: ['']
include:
- python-version: 3.9
- python-version: '3.9'
os: windows
registry: '0'
pytest-arg: 'tests/test_integration.py'
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ def random_name():

# If some test cases have used randomly-named temporary images,
# we need to clean up them!
if os.environ.get("CI", "") == "true":
if os.environ.get("CI") is not None:
# But inside the CI server, we don't need clean up!
return
event_loop = asyncio.get_event_loop()
event_loop = asyncio.new_event_loop()

async def _clean():
docker = Docker()
Expand Down Expand Up @@ -88,7 +88,7 @@ def image_name() -> str:
@pytest.fixture(scope="session")
def testing_images(image_name: str) -> None:
# Prepare a small Linux image shared by most test cases.
event_loop = asyncio.get_event_loop()
event_loop = asyncio.new_event_loop()

async def _pull():
docker = Docker()
Expand Down
14 changes: 7 additions & 7 deletions tests/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
import pytest


@pytest.mark.asyncio
def test_events_default_task(docker):
loop = asyncio.get_event_loop()
docker.events.subscribe()
assert docker.events.task is not None
loop.run_until_complete(docker.close())
await docker.close()
assert docker.events.task is None
assert docker.events.json_stream is None


@pytest.mark.asyncio
def test_events_provided_task(docker):
loop = asyncio.get_event_loop()
task = asyncio.ensure_future(docker.events.run())
docker.events.subscribe(create_task=False)
assert docker.events.task is None
task.cancel()
with pytest.raises(asyncio.CancelledError):
loop.run_until_complete(task)
loop.run_until_complete(docker.close())
await task
await docker.close()
assert docker.events.json_stream is None


@pytest.mark.asyncio
def test_events_no_task(docker):
loop = asyncio.get_event_loop()
assert docker.events.task is None
loop.run_until_complete(docker.close())
await docker.close()
assert docker.events.json_stream is None

0 comments on commit cce2af1

Please sign in to comment.