File tree 5 files changed +15
-31
lines changed
5 files changed +15
-31
lines changed Original file line number Diff line number Diff line change @@ -21,15 +21,9 @@ def config(unused_tcp_port_factory):
21
21
return c
22
22
23
23
24
- @pytest .fixture (scope = "session" )
25
- def event_loop (request ):
26
- loop = asyncio .get_event_loop_policy ().new_event_loop ()
27
- yield loop
28
- loop .close ()
29
-
30
-
31
24
@pytest_asyncio .fixture (scope = "session" )
32
25
async def server (event_loop , config ):
26
+ policy = asyncio .get_event_loop_policy ()
33
27
uvloop .install ()
34
28
try :
35
29
sd = asyncio .Event ()
@@ -38,6 +32,7 @@ async def server(event_loop, config):
38
32
finally :
39
33
sd .set ()
40
34
await task
35
+ asyncio .set_event_loop_policy (policy )
41
36
42
37
43
38
@pytest_asyncio .fixture (scope = "session" )
Original file line number Diff line number Diff line change @@ -35,15 +35,9 @@ def config(unused_tcp_port_factory):
35
35
return c
36
36
37
37
38
- @pytest .fixture (scope = "session" )
39
- def event_loop (request ):
40
- loop = asyncio .get_event_loop_policy ().new_event_loop ()
41
- yield loop
42
- loop .close ()
43
-
44
-
45
38
@pytest_asyncio .fixture (scope = "session" )
46
39
async def server (event_loop , config ):
40
+ policy = asyncio .get_event_loop_policy ()
47
41
uvloop .install ()
48
42
try :
49
43
sd = asyncio .Event ()
@@ -52,6 +46,7 @@ async def server(event_loop, config):
52
46
finally :
53
47
sd .set ()
54
48
await task
49
+ asyncio .set_event_loop_policy (policy )
55
50
56
51
57
52
@pytest .fixture (scope = "session" , params = [2 ])
Original file line number Diff line number Diff line change
1
+ import asyncio
1
2
import os
2
3
import dataclasses
3
4
import sys
16
17
URLBASE = "/"
17
18
18
19
20
+ @pytest .fixture (scope = "session" )
21
+ def event_loop (request ):
22
+ loop = asyncio .get_event_loop_policy ().new_event_loop ()
23
+ yield loop
24
+ loop .close ()
25
+
26
+
19
27
@pytest .fixture (autouse = True )
20
28
def skip_env (request ):
21
29
if request .node .get_closest_marker ("skip_env" ):
Original file line number Diff line number Diff line change @@ -269,24 +269,19 @@ def config(unused_tcp_port_factory):
269
269
return c
270
270
271
271
272
- @pytest .fixture (scope = "session" )
273
- def event_loop (request ):
274
- loop = asyncio .get_event_loop_policy ().new_event_loop ()
275
- yield loop
276
- loop .close ()
277
-
278
-
279
272
@pytest_asyncio .fixture (scope = "session" )
280
273
async def server (event_loop , config , app ):
281
- uvloop . install ()
274
+ policy = asyncio . get_event_loop_policy ()
282
275
try :
283
276
sd = asyncio .Event ()
284
277
asgi = WsgiToAsgi (app )
285
278
task = event_loop .create_task (serve (asgi , config , shutdown_trigger = sd .wait ))
286
279
yield config
287
280
finally :
288
281
sd .set ()
282
+ del asgi
289
283
await task
284
+ asyncio .set_event_loop_policy (policy )
290
285
291
286
292
287
@pytest .fixture (scope = "session" , params = ["application/x-www-form-urlencoded" , "multipart/form-data" ])
Original file line number Diff line number Diff line change 1
- import asyncio
2
-
3
1
import aiopenapi3 .plugin
4
2
from aiopenapi3 import OpenAPI
5
3
import pytest
@@ -70,13 +68,6 @@ def parsed(self, ctx):
70
68
return ctx
71
69
72
70
73
- @pytest_asyncio .fixture (scope = "session" )
74
- def event_loop (request ):
75
- loop = asyncio .get_event_loop_policy ().new_event_loop ()
76
- yield loop
77
- loop .close ()
78
-
79
-
80
71
@pytest_asyncio .fixture (scope = "session" )
81
72
async def api ():
82
73
from aiopenapi3 .loader import NullLoader , YAMLCompatibilityLoader
You can’t perform that action at this time.
0 commit comments