From 573cd8e94a5e061651897673fcc3ad00dfe33d45 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 1 May 2024 12:45:47 -0500 Subject: [PATCH] Ensure mock mqtt handler is cleaned up after test_bootstrap_dependencies (#116544) --- tests/test_bootstrap.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/test_bootstrap.py b/tests/test_bootstrap.py index 96caf5d10c8..782b082e639 100644 --- a/tests/test_bootstrap.py +++ b/tests/test_bootstrap.py @@ -1143,16 +1143,10 @@ async def test_bootstrap_empty_integrations( await hass.async_block_till_done() -@pytest.mark.parametrize("integration", ["mqtt_eventstream", "mqtt_statestream"]) -@pytest.mark.parametrize("load_registries", [False]) -async def test_bootstrap_dependencies( - hass: HomeAssistant, - caplog: pytest.LogCaptureFixture, - integration: str, -) -> None: - """Test dependencies are set up correctly,.""" +@pytest.fixture(name="mock_mqtt_config_flow") +def mock_mqtt_config_flow_fixture() -> Generator[None, None, None]: + """Mock MQTT config flow.""" - # Prepare MQTT config entry @HANDLERS.register("mqtt") class MockConfigFlow: """Mock the MQTT config flow.""" @@ -1160,6 +1154,19 @@ async def test_bootstrap_dependencies( VERSION = 1 MINOR_VERSION = 1 + yield + HANDLERS.pop("mqtt") + + +@pytest.mark.parametrize("integration", ["mqtt_eventstream", "mqtt_statestream"]) +@pytest.mark.parametrize("load_registries", [False]) +async def test_bootstrap_dependencies( + hass: HomeAssistant, + caplog: pytest.LogCaptureFixture, + integration: str, + mock_mqtt_config_flow: None, +) -> None: + """Test dependencies are set up correctly,.""" entry = MockConfigEntry(domain="mqtt", data={"broker": "test-broker"}) entry.add_to_hass(hass)