File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,9 @@ py_modules = asyncio_atexit
20
20
python_requires = >=3.6
21
21
22
22
[options.extras_require]
23
- test = pytest
23
+ test =
24
+ pytest
25
+ uvloop
24
26
25
27
[tool:pytest]
26
28
# asyncio_mode = auto
Original file line number Diff line number Diff line change 1
1
import asyncio
2
2
import sys
3
3
4
+ try :
5
+ import uvloop
6
+ except ImportError :
7
+ uvloop = None
8
+
9
+ import pytest
10
+
4
11
import asyncio_atexit
5
12
6
13
if sys .version_info >= (3 , 7 ):
@@ -15,7 +22,24 @@ def asyncio_run(coro):
15
22
loop .close ()
16
23
17
24
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 ):
19
43
sync_called = False
20
44
async_called = False
21
45
@@ -37,7 +61,7 @@ async def test():
37
61
assert async_called
38
62
39
63
40
- def test_unregister ():
64
+ def test_unregister (policy ):
41
65
sync_called = False
42
66
43
67
def sync_cb ():
You can’t perform that action at this time.
0 commit comments