Skip to content

Commit

Permalink
Update event_loop to explicitly set scope session
Browse files Browse the repository at this point in the history
As recommended by the deprecation warning

Signed-off-by: Mathias L. Baumann <[email protected]>
  • Loading branch information
Marenz committed Sep 30, 2024
1 parent 14d4510 commit 0287a09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ disable = [
[tool.pytest.ini_options]
testpaths = ["tests", "src"]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
required_plugins = ["pytest-asyncio", "pytest-mock"]

[tool.mypy]
Expand Down
10 changes: 5 additions & 5 deletions tests/test_mananging_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from typing import AsyncIterator, Iterator

import async_solipsism
import pytest
import time_machine
from frequenz.channels import Broadcast, Receiver, Sender
from frequenz.client.dispatch.test.generator import DispatchGenerator
Expand All @@ -20,11 +19,12 @@
from frequenz.dispatch import Dispatch, DispatchManagingActor, DispatchUpdate


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


@fixture
Expand Down

0 comments on commit 0287a09

Please sign in to comment.