1
mirror of https://github.com/home-assistant/core synced 2024-08-28 03:36:46 +02:00

Only mock config_entries.HANDLERS for the current test in mock_config_flow (#107357)

This commit is contained in:
Jan Bouwhuis 2024-01-06 11:46:12 +01:00 committed by GitHub
parent 65985c4e0b
commit d6aaaf1f1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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(