Do not allow coroutines to be passed to HassJob (#42073)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Paulus SchoutsenandJ. Nick Koston authored and GitHub committed 2020-10-19 23:25:33 +02:00
1 parent ec7f329807
commit b8417a2ce2
6 files changed
+39 -17

No files matched your search

+15
View File
@@ -1522,3 +1522,18 @@ async def test_async_entity_ids_count(hass):
assert hass.states.async_entity_ids_count() == 5
assert hass.states.async_entity_ids_count("light") == 3
async def test_hassjob_forbid_coroutine():
"""Test hassjob forbids coroutines."""
async def bla():
pass
coro = bla()
with pytest.raises(ValueError):
ha.HassJob(coro)
# To avoid warning about unawaited coro
await coro