Skip to content

Commit a6a315e

Browse files
committed
added workaround for pytest-dev/pytest-asyncio#30
1 parent b00d2ff commit a6a315e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/conftest.py

+15
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@
77
from aiorethink.registry import registry
88

99

10+
# WORKAROUND for https://github.com/pytest-dev/pytest-asyncio/issues/30
11+
@pytest.yield_fixture
12+
def event_loop():
13+
"""Create an instance of the default event loop for each test case."""
14+
policy = asyncio.get_event_loop_policy()
15+
res = policy.new_event_loop()
16+
asyncio.set_event_loop(res)
17+
res._close = res.close
18+
res.close = lambda: None
19+
20+
yield res
21+
22+
res._close()
23+
24+
1025
@pytest.fixture(scope = "session")
1126
def _db_config():
1227
# configure DB exactly once

0 commit comments

Comments
 (0)