From ecf4a7813a7d868578a74fd8a61d18b0cf8164bf Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Fri, 17 Sep 2021 15:27:26 +0200 Subject: [PATCH] Prevent 3rd party lib from opening sockets in wilight tests (#56310) --- tests/components/wilight/test_init.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/components/wilight/test_init.py b/tests/components/wilight/test_init.py index 24efdaaa8e1..5aadce3caea 100644 --- a/tests/components/wilight/test_init.py +++ b/tests/components/wilight/test_init.py @@ -4,6 +4,7 @@ from unittest.mock import patch import pytest import pywilight from pywilight.const import DOMAIN +import requests from homeassistant.config_entries import ConfigEntryState from homeassistant.core import HomeAssistant @@ -41,7 +42,11 @@ def mock_dummy_device_from_host(): async def test_config_entry_not_ready(hass: HomeAssistant) -> None: """Test the WiLight configuration entry not ready.""" - entry = await setup_integration(hass) + with patch( + "pywilight.device_from_host", + side_effect=requests.exceptions.Timeout, + ): + entry = await setup_integration(hass) assert entry.state is ConfigEntryState.SETUP_RETRY