Skip to content

Commit b9ccd07

Browse files
committed
Make api an async fixture to grab reference to loop early
1 parent 69224d1 commit b9ccd07

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests/test_api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ def gateway():
3030

3131

3232
@pytest.fixture
33-
def api(gateway, mock_command_rsp):
33+
async def api(gateway, mock_command_rsp):
34+
loop = asyncio.get_running_loop()
35+
3436
async def mock_connect(config, api):
3537
transport = MagicMock()
3638
transport.close = MagicMock(
37-
side_effect=lambda: asyncio.get_running_loop().call_soon(
38-
gateway.connection_lost, None
39-
)
39+
side_effect=lambda: loop.call_soon(gateway.connection_lost, None)
4040
)
4141

4242
gateway._api = api

0 commit comments

Comments
 (0)