File tree 2 files changed +34
-1
lines changed
2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ def pytest_pyfunc_call(pyfuncitem):
45
45
testargs = {arg : funcargs [arg ]
46
46
for arg in pyfuncitem ._fixtureinfo .argnames }
47
47
event_loop .run_until_complete (
48
- asyncio .async (pyfuncitem .obj (** testargs )))
48
+ asyncio .async (pyfuncitem .obj (** testargs ), loop = event_loop ))
49
49
return True
50
50
51
51
Original file line number Diff line number Diff line change
1
+ import asyncio
2
+
3
+ import pytest
4
+
5
+
6
+ def setup_module (module ):
7
+ asyncio .set_event_loop (None )
8
+
9
+
10
+ def teardown_module (module ):
11
+ # restore the default policy
12
+ asyncio .set_event_loop_policy (None )
13
+
14
+
15
+ @pytest .fixture
16
+ def event_loop (request ):
17
+ loop = asyncio .new_event_loop ()
18
+ request .addfinalizer (loop .close )
19
+ return loop
20
+
21
+
22
+ @asyncio .coroutine
23
+ def example_coroutine ():
24
+ return 42
25
+
26
+
27
+ @pytest .mark .asyncio
28
+ def test_asyncio_marker_with_non_global_loop (event_loop ):
29
+ with pytest .raises (RuntimeError ):
30
+ _ = asyncio .get_event_loop ()
31
+
32
+ result = yield from example_coroutine ()
33
+
You can’t perform that action at this time.
0 commit comments