We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0f3609c commit 4dd88c3Copy full SHA for 4dd88c3
tests/conftest.py
@@ -6,8 +6,16 @@
6
7
@pytest.fixture(scope="session")
8
def event_loop():
9
- """Force the pytest-asyncio loop to be the main one."""
10
- loop = asyncio.get_event_loop()
+ """
+ Force the pytest-asyncio loop to be the main one.
11
+ If there is no running event loop, create one and
12
+ set as the current one.
13
14
+ try:
15
+ loop = asyncio.get_running_loop()
16
+ except RuntimeError:
17
+ loop = asyncio.new_event_loop()
18
+ asyncio.set_event_loop(loop)
19
yield loop
20
21
0 commit comments