Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,30 @@ def pytest_collection_modifyitems(config, items):


pytest_plugins = ["distributed.pytest_resourceleaks"]

# The following fixtures are required for pytest-asyncio compatibility


@pytest.fixture()
def event_loop():
from distributed.utils_test import clean

with clean() as loop:
yield loop.asyncio_loop


@pytest.hookimpl(trylast=True)
def pytest_fixture_post_finalizer(fixturedef, request):
"""Pytest-asyncio resets the eventloop policy after the above event loop is closed."""
import asyncio

if fixturedef.argname == "event_loop":
try:
# Tornado > 6.0.3
from tornado.platform.asyncio import AnyThreadEventLoopPolicy
except ImportError:
try:
from distributed.utils import AnyThreadEventLoopPolicy
except ImportError:
return
asyncio.set_event_loop_policy(AnyThreadEventLoopPolicy())
2 changes: 1 addition & 1 deletion continuous_integration/environment-3.7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:
- prometheus_client
- psutil
- pytest
- pytest-asyncio<0.14.0
- pytest-asyncio
- pytest-faulthandler
- pytest-repeat
- pytest-rerunfailures
Expand Down
2 changes: 1 addition & 1 deletion continuous_integration/environment-3.8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies:
- prometheus_client
- psutil
- pytest
- pytest-asyncio<0.14.0
- pytest-asyncio
- pytest-faulthandler
- pytest-repeat
- pytest-rerunfailures
Expand Down
2 changes: 1 addition & 1 deletion continuous_integration/environment-3.9.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:
- prometheus_client
- psutil
- pytest
- pytest-asyncio<0.14.0
- pytest-asyncio
- pytest-faulthandler
- pytest-repeat
- pytest-rerunfailures
Expand Down