Skip to content

Commit 0287a09

Browse files
committed
Update event_loop to explicitly set scope session
As recommended by the deprecation warning Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent 14d4510 commit 0287a09

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ disable = [
165165
[tool.pytest.ini_options]
166166
testpaths = ["tests", "src"]
167167
asyncio_mode = "auto"
168+
asyncio_default_fixture_loop_scope = "function"
168169
required_plugins = ["pytest-asyncio", "pytest-mock"]
169170

170171
[tool.mypy]

tests/test_mananging_actor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from typing import AsyncIterator, Iterator
1010

1111
import async_solipsism
12-
import pytest
1312
import time_machine
1413
from frequenz.channels import Broadcast, Receiver, Sender
1514
from frequenz.client.dispatch.test.generator import DispatchGenerator
@@ -20,11 +19,12 @@
2019
from frequenz.dispatch import Dispatch, DispatchManagingActor, DispatchUpdate
2120

2221

23-
# This method replaces the event loop for all tests in the file.
24-
@pytest.fixture
22+
@fixture
2523
def event_loop_policy() -> async_solipsism.EventLoopPolicy:
26-
"""Return an event loop policy that uses the async solipsism event loop."""
27-
return async_solipsism.EventLoopPolicy()
24+
"""Set the event loop policy to use async_solipsism."""
25+
policy = async_solipsism.EventLoopPolicy()
26+
asyncio.set_event_loop_policy(policy)
27+
return policy
2828

2929

3030
@fixture

0 commit comments

Comments
 (0)