diff --git a/tests/test_asyncio.py b/tests/test_asyncio.py index f187980..263201f 100644 --- a/tests/test_asyncio.py +++ b/tests/test_asyncio.py @@ -1,9 +1,9 @@ # License: MIT # Copyright © 2022 Frequenz Energy-as-a-Service GmbH -"""Simple test for the BaseActor.""" +"""Tests for the asyncio module.""" + import asyncio -from collections.abc import Iterator from typing import Literal, assert_never import async_solipsism @@ -12,13 +12,11 @@ from frequenz.core.asyncio import BackgroundService -# Setting 'autouse' has no effect as this method replaces the event loop for all tests in the file. -@pytest.fixture() -def event_loop() -> Iterator[async_solipsism.EventLoop]: - """Replace the loop with one that doesn't interact with the outside world.""" - loop = async_solipsism.EventLoop() - yield loop - loop.close() +# This method replaces the event loop for all tests in the file. +@pytest.fixture +def event_loop_policy() -> async_solipsism.EventLoopPolicy: + """Return an event loop policy that uses the async solipsism event loop.""" + return async_solipsism.EventLoopPolicy() class FakeService(BackgroundService):