@@ -85,7 +85,7 @@ def test_split_entity_id() -> None:
85
85
ha .split_entity_id (".empty_domain" )
86
86
87
87
88
- def test_async_add_hass_job_schedule_callback () -> None :
88
+ async def test_async_add_hass_job_schedule_callback () -> None :
89
89
"""Test that we schedule callbacks and add jobs to the job pool."""
90
90
hass = MagicMock ()
91
91
job = MagicMock ()
@@ -96,7 +96,7 @@ def test_async_add_hass_job_schedule_callback() -> None:
96
96
assert len (hass .add_job .mock_calls ) == 0
97
97
98
98
99
- def test_async_add_hass_job_coro_named (hass : HomeAssistant ) -> None :
99
+ async def test_async_add_hass_job_coro_named (hass : HomeAssistant ) -> None :
100
100
"""Test that we schedule coroutines and add jobs to the job pool with a name."""
101
101
102
102
async def mycoro ():
@@ -109,7 +109,7 @@ async def mycoro():
109
109
assert "named coro" in str (task )
110
110
111
111
112
- def test_async_add_hass_job_schedule_partial_callback () -> None :
112
+ async def test_async_add_hass_job_schedule_partial_callback () -> None :
113
113
"""Test that we schedule partial coros and add jobs to the job pool."""
114
114
hass = MagicMock ()
115
115
job = MagicMock ()
@@ -121,9 +121,9 @@ def test_async_add_hass_job_schedule_partial_callback() -> None:
121
121
assert len (hass .add_job .mock_calls ) == 0
122
122
123
123
124
- def test_async_add_hass_job_schedule_coroutinefunction (event_loop ) -> None :
124
+ async def test_async_add_hass_job_schedule_coroutinefunction () -> None :
125
125
"""Test that we schedule coroutines and add jobs to the job pool."""
126
- hass = MagicMock (loop = MagicMock (wraps = event_loop ))
126
+ hass = MagicMock (loop = MagicMock (wraps = asyncio . get_running_loop () ))
127
127
128
128
async def job ():
129
129
pass
@@ -134,9 +134,9 @@ async def job():
134
134
assert len (hass .add_job .mock_calls ) == 0
135
135
136
136
137
- def test_async_add_hass_job_schedule_partial_coroutinefunction (event_loop ) -> None :
137
+ async def test_async_add_hass_job_schedule_partial_coroutinefunction () -> None :
138
138
"""Test that we schedule partial coros and add jobs to the job pool."""
139
- hass = MagicMock (loop = MagicMock (wraps = event_loop ))
139
+ hass = MagicMock (loop = MagicMock (wraps = asyncio . get_running_loop () ))
140
140
141
141
async def job ():
142
142
pass
@@ -149,7 +149,7 @@ async def job():
149
149
assert len (hass .add_job .mock_calls ) == 0
150
150
151
151
152
- def test_async_add_job_add_hass_threaded_job_to_pool () -> None :
152
+ async def test_async_add_job_add_hass_threaded_job_to_pool () -> None :
153
153
"""Test that we schedule coroutines and add jobs to the job pool."""
154
154
hass = MagicMock ()
155
155
@@ -162,11 +162,9 @@ def job():
162
162
assert len (hass .loop .run_in_executor .mock_calls ) == 2
163
163
164
164
165
- def test_async_create_task_schedule_coroutine (
166
- event_loop : asyncio .AbstractEventLoop ,
167
- ) -> None :
165
+ async def test_async_create_task_schedule_coroutine () -> None :
168
166
"""Test that we schedule coroutines and add jobs to the job pool."""
169
- hass = MagicMock (loop = MagicMock (wraps = event_loop ))
167
+ hass = MagicMock (loop = MagicMock (wraps = asyncio . get_running_loop () ))
170
168
171
169
async def job ():
172
170
pass
@@ -180,11 +178,9 @@ async def job():
180
178
@pytest .mark .skipif (
181
179
sys .version_info < (3 , 12 ), reason = "eager_start is only supported for Python 3.12"
182
180
)
183
- def test_async_create_task_eager_start_schedule_coroutine (
184
- event_loop : asyncio .AbstractEventLoop ,
185
- ) -> None :
181
+ async def test_async_create_task_eager_start_schedule_coroutine () -> None :
186
182
"""Test that we schedule coroutines and add jobs to the job pool."""
187
- hass = MagicMock (loop = MagicMock (wraps = event_loop ))
183
+ hass = MagicMock (loop = MagicMock (wraps = asyncio . get_running_loop () ))
188
184
189
185
async def job ():
190
186
pass
@@ -198,11 +194,9 @@ async def job():
198
194
@pytest .mark .skipif (
199
195
sys .version_info >= (3 , 12 ), reason = "eager_start is not supported on < 3.12"
200
196
)
201
- def test_async_create_task_eager_start_fallback_schedule_coroutine (
202
- event_loop : asyncio .AbstractEventLoop ,
203
- ) -> None :
197
+ async def test_async_create_task_eager_start_fallback_schedule_coroutine () -> None :
204
198
"""Test that we schedule coroutines and add jobs to the job pool."""
205
- hass = MagicMock (loop = MagicMock (wraps = event_loop ))
199
+ hass = MagicMock (loop = MagicMock (wraps = asyncio . get_running_loop () ))
206
200
207
201
async def job ():
208
202
pass
@@ -215,9 +209,9 @@ async def job():
215
209
assert len (hass .add_job .mock_calls ) == 0
216
210
217
211
218
- def test_async_create_task_schedule_coroutine_with_name (event_loop ) -> None :
212
+ async def test_async_create_task_schedule_coroutine_with_name () -> None :
219
213
"""Test that we schedule coroutines and add jobs to the job pool with a name."""
220
- hass = MagicMock (loop = MagicMock (wraps = event_loop ))
214
+ hass = MagicMock (loop = MagicMock (wraps = asyncio . get_running_loop () ))
221
215
222
216
async def job ():
223
217
pass
@@ -229,7 +223,7 @@ async def job():
229
223
assert "named task" in str (task )
230
224
231
225
232
- def test_async_run_hass_job_calls_callback () -> None :
226
+ async def test_async_run_hass_job_calls_callback () -> None :
233
227
"""Test that the callback annotation is respected."""
234
228
hass = MagicMock ()
235
229
calls = []
@@ -242,7 +236,7 @@ def job():
242
236
assert len (hass .async_add_job .mock_calls ) == 0
243
237
244
238
245
- def test_async_run_hass_job_delegates_non_async () -> None :
239
+ async def test_async_run_hass_job_delegates_non_async () -> None :
246
240
"""Test that the callback annotation is respected."""
247
241
hass = MagicMock ()
248
242
calls = []
0 commit comments