Skip to content

Commit 03a3c36

Browse files
committed
Added asyncio loop to BaseTestCase
1 parent fb5c4e0 commit 03a3c36

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

tests/protocol/__init__.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
import unittest
23
from typing import cast
34
from unittest import mock
@@ -53,12 +54,15 @@ def setUp(self):
5354
).proxy(),
5455
)
5556

57+
self.loop = asyncio.new_event_loop()
58+
asyncio.set_event_loop(self.loop)
5659
self.connection = MockConnection()
5760
self.session = session.MpdSession(
5861
config=self.get_config(),
5962
core=self.core,
6063
uri_map=uri_mapper.MpdUriMapper(self.core),
6164
connection=self.connection,
65+
loop=self.loop,
6266
)
6367
self.dispatcher = self.session.dispatcher
6468
self.context = self.dispatcher.context
@@ -76,20 +80,20 @@ def assertNoResponse(self): # noqa: N802
7680
assert self.connection.response == []
7781

7882
def assertInResponse(self, value): # noqa: N802
79-
assert value in self.connection.response, (
80-
f"Did not find {value!r} in {self.connection.response!r}"
81-
)
83+
assert (
84+
value in self.connection.response
85+
), f"Did not find {value!r} in {self.connection.response!r}"
8286

8387
def assertOnceInResponse(self, value): # noqa: N802
8488
matched = len([r for r in self.connection.response if r == value])
85-
assert matched == 1, (
86-
f"Expected to find {value!r} once in {self.connection.response!r}"
87-
)
89+
assert (
90+
matched == 1
91+
), f"Expected to find {value!r} once in {self.connection.response!r}"
8892

8993
def assertNotInResponse(self, value): # noqa: N802
90-
assert value not in self.connection.response, (
91-
f"Found {value!r} in {self.connection.response!r}"
92-
)
94+
assert (
95+
value not in self.connection.response
96+
), f"Found {value!r} in {self.connection.response!r}"
9397

9498
def assertEqualResponse(self, value): # noqa: N802
9599
assert len(self.connection.response) == 1

0 commit comments

Comments
 (0)