Skip to content

Commit 4587753

Browse files
authored
Fix asyncio's module tests (#16)
2 parents cbd6962 + c0fd71d commit 4587753

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

tests/test_asyncio.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# License: MIT
22
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
33

4-
"""Simple test for the BaseActor."""
4+
"""Tests for the asyncio module."""
5+
56
import asyncio
6-
from collections.abc import Iterator
77
from typing import Literal, assert_never
88

99
import async_solipsism
@@ -12,13 +12,11 @@
1212
from frequenz.core.asyncio import BackgroundService
1313

1414

15-
# Setting 'autouse' has no effect as this method replaces the event loop for all tests in the file.
16-
@pytest.fixture()
17-
def event_loop() -> Iterator[async_solipsism.EventLoop]:
18-
"""Replace the loop with one that doesn't interact with the outside world."""
19-
loop = async_solipsism.EventLoop()
20-
yield loop
21-
loop.close()
15+
# This method replaces the event loop for all tests in the file.
16+
@pytest.fixture
17+
def event_loop_policy() -> async_solipsism.EventLoopPolicy:
18+
"""Return an event loop policy that uses the async solipsism event loop."""
19+
return async_solipsism.EventLoopPolicy()
2220

2321

2422
class FakeService(BackgroundService):

0 commit comments

Comments
 (0)