From ea55051161ee5443c9df60ae8b601478800bc02f Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 27 Nov 2020 12:53:16 +0100 Subject: [PATCH] Stub finding custom integrations in tests (#43692) --- tests/common.py | 2 ++ tests/conftest.py | 6 ++++++ tests/test_loader.py | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/common.py b/tests/common.py index dbe2cbfd42a..66303ad96b3 100644 --- a/tests/common.py +++ b/tests/common.py @@ -195,6 +195,8 @@ async def async_test_home_assistant(loop): hass.async_add_executor_job = async_add_executor_job hass.async_create_task = async_create_task + hass.data[loader.DATA_CUSTOM_COMPONENTS] = {} + hass.config.location_name = "test home" hass.config.config_dir = get_test_config_dir() hass.config.latitude = 32.87336 diff --git a/tests/conftest.py b/tests/conftest.py index d5c4c61ddf1..fa390f9bf3b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -537,3 +537,9 @@ def legacy_patchable_time(): async_track_utc_time_change, ): yield + + +@pytest.fixture +def enable_custom_integrations(hass): + """Enable custom integrations defined in the test dir.""" + hass.data.pop(loader.DATA_CUSTOM_COMPONENTS) diff --git a/tests/test_loader.py b/tests/test_loader.py index 71a373a579d..69e6688b9de 100644 --- a/tests/test_loader.py +++ b/tests/test_loader.py @@ -149,7 +149,7 @@ async def test_get_integration_legacy(hass): assert integration.get_platform("switch") is not None -async def test_get_integration_custom_component(hass): +async def test_get_integration_custom_component(hass, enable_custom_integrations): """Test resolving integration.""" integration = await loader.async_get_integration(hass, "test_package") print(integration) @@ -293,7 +293,7 @@ def _get_test_integration_with_zeroconf_matcher(hass, name, config_flow): ) -async def test_get_custom_components(hass): +async def test_get_custom_components(hass, enable_custom_integrations): """Verify that custom components are cached.""" test_1_integration = _get_test_integration(hass, "test_1", False) test_2_integration = _get_test_integration(hass, "test_2", True)