diff --git a/tests/components/nuki/test_binary_sensor.py b/tests/components/nuki/test_binary_sensor.py index 20551a66307..9b09c749d73 100644 --- a/tests/components/nuki/test_binary_sensor.py +++ b/tests/components/nuki/test_binary_sensor.py @@ -27,3 +27,9 @@ async def test_binary_sensors( entry = await init_integration(hass, mock_nuki_requests) await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id) + + # Unload the config entry after taking a snapshot is required because the integration may cache + # DNS results or keep references to the original gethostbyname, so unloading ensures the patch + # is effective for subsequent tests and avoids DNS lookups + await hass.config_entries.async_unload(entry.entry_id) + await hass.async_block_till_done() diff --git a/tests/components/nuki/test_lock.py b/tests/components/nuki/test_lock.py index 6d8c3cc43fc..ec3b42e4d59 100644 --- a/tests/components/nuki/test_lock.py +++ b/tests/components/nuki/test_lock.py @@ -25,3 +25,9 @@ async def test_locks( entry = await init_integration(hass, mock_nuki_requests) await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id) + + # Unload the config entry after taking a snapshot is required because the integration may cache + # DNS results or keep references to the original gethostbyname, so unloading ensures the patch + # is effective for subsequent tests and avoids DNS lookups + await hass.config_entries.async_unload(entry.entry_id) + await hass.async_block_till_done() diff --git a/tests/components/nuki/test_sensor.py b/tests/components/nuki/test_sensor.py index d03fe7f0da6..8989cf853c9 100644 --- a/tests/components/nuki/test_sensor.py +++ b/tests/components/nuki/test_sensor.py @@ -25,3 +25,9 @@ async def test_sensors( entry = await init_integration(hass, mock_nuki_requests) await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id) + + # Unload the config entry after taking a snapshot is required because the integration may cache + # DNS results or keep references to the original gethostbyname, so unloading ensures the patch + # is effective for subsequent tests and avoids DNS lookups + await hass.config_entries.async_unload(entry.entry_id) + await hass.async_block_till_done()