From 376a6eb82ad8c73cbbe664d3bc2a5c70a0bbfaa1 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Sun, 12 Mar 2023 14:48:46 +0100 Subject: [PATCH] Convert device_sun_light_trigger test fixture to async (#89578) --- .../device_sun_light_trigger/test_init.py | 23 +++++++++---------- .../custom_components/test/device_tracker.py | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/tests/components/device_sun_light_trigger/test_init.py b/tests/components/device_sun_light_trigger/test_init.py index 0c5a9ccab145..6b563f1cb5fd 100644 --- a/tests/components/device_sun_light_trigger/test_init.py +++ b/tests/components/device_sun_light_trigger/test_init.py @@ -28,9 +28,11 @@ from tests.common import async_fire_time_changed @pytest.fixture -def scanner(hass, enable_custom_integrations): +async def scanner(hass, enable_custom_integrations): """Initialize components.""" - scanner = getattr(hass.components, "test.device_tracker").get_scanner(None, None) + scanner = await getattr(hass.components, "test.device_tracker").async_get_scanner( + None, None + ) scanner.reset() scanner.come_home("DEV1") @@ -56,19 +58,16 @@ def scanner(hass, enable_custom_integrations): }, }, ): - assert hass.loop.run_until_complete( - async_setup_component( - hass, - device_tracker.DOMAIN, - {device_tracker.DOMAIN: {CONF_PLATFORM: "test"}}, - ) + assert await async_setup_component( + hass, + device_tracker.DOMAIN, + {device_tracker.DOMAIN: {CONF_PLATFORM: "test"}}, ) - assert hass.loop.run_until_complete( - async_setup_component( - hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}} - ) + assert await async_setup_component( + hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}} ) + await hass.async_block_till_done() return scanner diff --git a/tests/testing_config/custom_components/test/device_tracker.py b/tests/testing_config/custom_components/test/device_tracker.py index d5f34f48ec8b..31294a48e3d5 100644 --- a/tests/testing_config/custom_components/test/device_tracker.py +++ b/tests/testing_config/custom_components/test/device_tracker.py @@ -5,7 +5,7 @@ from homeassistant.components.device_tracker.config_entry import ScannerEntity from homeassistant.components.device_tracker.const import SOURCE_TYPE_ROUTER -def get_scanner(hass, config): +async def async_get_scanner(hass, config): """Return a mock scanner.""" return SCANNER