Ensure mqtt handler is restored if its already registered in bootstrap test (#116549)

pull/116553/head
J. Nick Koston 2024-05-01 13:22:18 -05:00 committed by GitHub
parent 573cd8e94a
commit f73c55b434
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -1146,6 +1146,7 @@ async def test_bootstrap_empty_integrations(
@pytest.fixture(name="mock_mqtt_config_flow")
def mock_mqtt_config_flow_fixture() -> Generator[None, None, None]:
"""Mock MQTT config flow."""
original_mqtt = HANDLERS.get("mqtt")
@HANDLERS.register("mqtt")
class MockConfigFlow:
@ -1155,7 +1156,10 @@ def mock_mqtt_config_flow_fixture() -> Generator[None, None, None]:
MINOR_VERSION = 1
yield
HANDLERS.pop("mqtt")
if original_mqtt:
HANDLERS["mqtt"] = original_mqtt
else:
HANDLERS.pop("mqtt")
@pytest.mark.parametrize("integration", ["mqtt_eventstream", "mqtt_statestream"])