From d6aaaf1f1add7d84454c3c5b10824e0bd8c29cac Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Sat, 6 Jan 2024 11:46:12 +0100 Subject: [PATCH] Only mock config_entries.HANDLERS for the current test in mock_config_flow (#107357) --- tests/common.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/common.py b/tests/common.py index 85193022e4f..c6a0660be73 100644 --- a/tests/common.py +++ b/tests/common.py @@ -1316,12 +1316,8 @@ async def get_system_health_info(hass: HomeAssistant, domain: str) -> dict[str, @contextmanager def mock_config_flow(domain: str, config_flow: type[ConfigFlow]) -> None: """Mock a config flow handler.""" - handler = config_entries.HANDLERS.get(domain) - config_entries.HANDLERS[domain] = config_flow - _LOGGER.info("Adding mock config flow: %s", domain) - yield - if handler: - config_entries.HANDLERS[domain] = handler + with patch.dict(config_entries.HANDLERS, {domain: config_flow}): + yield def mock_integration(