1
+ import asyncio
1
2
import unittest
2
3
from typing import cast
3
4
from unittest import mock
@@ -53,12 +54,15 @@ def setUp(self):
53
54
).proxy (),
54
55
)
55
56
57
+ self .loop = asyncio .new_event_loop ()
58
+ asyncio .set_event_loop (self .loop )
56
59
self .connection = MockConnection ()
57
60
self .session = session .MpdSession (
58
61
config = self .get_config (),
59
62
core = self .core ,
60
63
uri_map = uri_mapper .MpdUriMapper (self .core ),
61
64
connection = self .connection ,
65
+ loop = self .loop ,
62
66
)
63
67
self .dispatcher = self .session .dispatcher
64
68
self .context = self .dispatcher .context
@@ -76,20 +80,20 @@ def assertNoResponse(self): # noqa: N802
76
80
assert self .connection .response == []
77
81
78
82
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 } "
82
86
83
87
def assertOnceInResponse (self , value ): # noqa: N802
84
88
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 } "
88
92
89
93
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 } "
93
97
94
98
def assertEqualResponse (self , value ): # noqa: N802
95
99
assert len (self .connection .response ) == 1
0 commit comments