1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Catch all exceptions on import component/platform (#64930)

This commit is contained in:
Paulus Schoutsen
2022-01-25 20:39:32 -08:00
committed by GitHub
parent a24f79434f
commit 24546dfdf9
4 changed files with 48 additions and 10 deletions

View File

@@ -157,6 +157,21 @@ async def test_get_integration(hass):
assert hue_light == integration.get_platform("light")
async def test_get_integration_exceptions(hass):
"""Test resolving integration."""
integration = await loader.async_get_integration(hass, "hue")
with pytest.raises(ImportError), patch(
"homeassistant.loader.importlib.import_module", side_effect=ValueError("Boom")
):
assert hue == integration.get_component()
with pytest.raises(ImportError), patch(
"homeassistant.loader.importlib.import_module", side_effect=ValueError("Boom")
):
assert hue_light == integration.get_platform("light")
async def test_get_integration_legacy(hass, enable_custom_integrations):
"""Test resolving integration."""
integration = await loader.async_get_integration(hass, "test_embedded")