Skip to content

Commit fb1e4ce

Browse files
committed
test with uvloop
1 parent a1807ab commit fb1e4ce

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

setup.cfg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ py_modules = asyncio_atexit
2020
python_requires = >=3.6
2121

2222
[options.extras_require]
23-
test = pytest
23+
test =
24+
pytest
25+
uvloop
2426

2527
[tool:pytest]
2628
# asyncio_mode = auto

test_asyncio_atexit.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import asyncio
22
import sys
33

4+
try:
5+
import uvloop
6+
except ImportError:
7+
uvloop = None
8+
9+
import pytest
10+
411
import asyncio_atexit
512

613
if sys.version_info >= (3, 7):
@@ -15,7 +22,24 @@ def asyncio_run(coro):
1522
loop.close()
1623

1724

18-
def test_asyncio_atexit():
25+
policies = ["default"]
26+
if uvloop is not None:
27+
policies.append("uvloop")
28+
29+
30+
@pytest.fixture(params=policies)
31+
def policy(request):
32+
before_policy = asyncio.get_event_loop_policy()
33+
if request.param == "default":
34+
policy = asyncio.DefaultEventLoopPolicy()
35+
elif request.param == "uvloop":
36+
policy = uvloop.EventLoopPolicy()
37+
asyncio.set_event_loop_policy(policy)
38+
yield
39+
asyncio.set_event_loop_policy(before_policy)
40+
41+
42+
def test_asyncio_atexit(policy):
1943
sync_called = False
2044
async_called = False
2145

@@ -37,7 +61,7 @@ async def test():
3761
assert async_called
3862

3963

40-
def test_unregister():
64+
def test_unregister(policy):
4165
sync_called = False
4266

4367
def sync_cb():

0 commit comments

Comments
 (0)