Skip to content

Commit

Permalink
Update conftest
Browse files Browse the repository at this point in the history
  • Loading branch information
vxgmichel committed Apr 29, 2024
1 parent 236380e commit c6beb96
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import pytest
import asyncio
import platform


def import_uvloop():
try:
import uvloop
except ImportError:
return None
else:
return uvloop


@pytest.fixture(
Expand All @@ -13,14 +21,16 @@ def event_loop_policy(request):
if request.param == "default":
return asyncio.DefaultEventLoopPolicy()
elif request.param == "uvloop":
if platform.python_implementation() == "PyPy":
pytest.skip("Skip uvloop tests on PyPy.")
import uvloop

uvloop = import_uvloop()
if uvloop is None:
pytest.skip("uvloop is not installed")
return uvloop.EventLoopPolicy()
return request.param


@pytest.fixture
def is_uvloop(event_loop_policy):
return not isinstance(event_loop_policy, asyncio.DefaultEventLoopPolicy)
uvloop = import_uvloop()
if uvloop is None:
return False
return isinstance(event_loop_policy, uvloop.EventLoopPolicy)

0 comments on commit c6beb96

Please sign in to comment.