From 3d0221de04bf86cdd8f747af1678d8b4531aa732 Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Sat, 5 Sep 2026 12:55:18 -0700 Subject: [PATCH 1/2] Fix cloud support package snapshots with verbose logging --- tests/components/cloud/test_http_api.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/components/cloud/test_http_api.py b/tests/components/cloud/test_http_api.py index 3d57ac36f5e17..e259f69c6698f 100644 --- a/tests/components/cloud/test_http_api.py +++ b/tests/components/cloud/test_http_api.py @@ -2925,9 +2925,13 @@ async def test_download_support_package_custom_components_error( aioclient_mock: AiohttpClientMocker, freezer: FrozenDateTimeFactory, snapshot: SnapshotAssertion, + caplog: pytest.LogCaptureFixture, ) -> None: """Test download support package when async_get_custom_components fails.""" + # Exclude setup logs with nondeterministic timestamps in verbose runs. + caplog.set_level(logging.INFO, logger="hass_nabucasa.events.bus") + aioclient_mock.get("https://cloud.bla.com/status", text="") aioclient_mock.get( "https://cert-server/directory", exc=Exception("Unexpected exception") @@ -3044,9 +3048,13 @@ async def test_download_support_package_integration_load_error( aioclient_mock: AiohttpClientMocker, freezer: FrozenDateTimeFactory, snapshot: SnapshotAssertion, + caplog: pytest.LogCaptureFixture, ) -> None: """Test download support package when async_get_loaded_integration fails.""" + # Exclude setup logs with nondeterministic timestamps in verbose runs. + caplog.set_level(logging.INFO, logger="hass_nabucasa.events.bus") + aioclient_mock.get("https://cloud.bla.com/status", text="") aioclient_mock.get( "https://cert-server/directory", exc=Exception("Unexpected exception") From 1645ef0f45e493ebc184d5f99d25bb828ab14593 Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Mon, 7 Sep 2026 22:18:54 -0700 Subject: [PATCH 2/2] Use bounded log queues in cloud support package tests --- tests/components/cloud/snapshots/test_http_api.ambr | 2 -- tests/components/cloud/test_http_api.py | 10 ++-------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/tests/components/cloud/snapshots/test_http_api.ambr b/tests/components/cloud/snapshots/test_http_api.ambr index 8be82b31bc8c1..f15149189a55e 100644 --- a/tests/components/cloud/snapshots/test_http_api.ambr +++ b/tests/components/cloud/snapshots/test_http_api.ambr @@ -238,7 +238,6 @@
Logs ```logs - 2025-02-10 12:00:00.000 INFO (MainThread) [hass_nabucasa.iot] This message will be dropped since this test patches MAX_RECORDS 2025-02-10 12:00:00.000 INFO (MainThread) [hass_nabucasa.iot] Hass nabucasa log 2025-02-10 12:00:00.000 WARNING (MainThread) [snitun.utils.aiohttp_client] Snitun log 2025-02-10 12:00:00.000 ERROR (MainThread) [homeassistant.components.cloud.client] Cloud log @@ -320,7 +319,6 @@
Logs ```logs - 2025-02-10 12:00:00.000 INFO (MainThread) [hass_nabucasa.iot] This message will be dropped since this test patches MAX_RECORDS 2025-02-10 12:00:00.000 INFO (MainThread) [hass_nabucasa.iot] Hass nabucasa log 2025-02-10 12:00:00.000 WARNING (MainThread) [snitun.utils.aiohttp_client] Snitun log 2025-02-10 12:00:00.000 ERROR (MainThread) [homeassistant.components.cloud.client] Cloud log diff --git a/tests/components/cloud/test_http_api.py b/tests/components/cloud/test_http_api.py index e259f69c6698f..9ce8c3b7e8488 100644 --- a/tests/components/cloud/test_http_api.py +++ b/tests/components/cloud/test_http_api.py @@ -2916,6 +2916,7 @@ async def mock_empty_info(hass: HomeAssistant) -> dict[str, Any]: assert await req.text() == snapshot +@patch("homeassistant.components.cloud.helpers.FixedSizeQueueLogHandler.MAX_RECORDS", 3) @pytest.mark.usefixtures("enable_custom_integrations") async def test_download_support_package_custom_components_error( hass: HomeAssistant, @@ -2925,13 +2926,9 @@ async def test_download_support_package_custom_components_error( aioclient_mock: AiohttpClientMocker, freezer: FrozenDateTimeFactory, snapshot: SnapshotAssertion, - caplog: pytest.LogCaptureFixture, ) -> None: """Test download support package when async_get_custom_components fails.""" - # Exclude setup logs with nondeterministic timestamps in verbose runs. - caplog.set_level(logging.INFO, logger="hass_nabucasa.events.bus") - aioclient_mock.get("https://cloud.bla.com/status", text="") aioclient_mock.get( "https://cert-server/directory", exc=Exception("Unexpected exception") @@ -3039,6 +3036,7 @@ async def mock_empty_info(hass: HomeAssistant) -> dict[str, Any]: assert await req.text() == snapshot +@patch("homeassistant.components.cloud.helpers.FixedSizeQueueLogHandler.MAX_RECORDS", 3) @pytest.mark.usefixtures("enable_custom_integrations") async def test_download_support_package_integration_load_error( hass: HomeAssistant, @@ -3048,13 +3046,9 @@ async def test_download_support_package_integration_load_error( aioclient_mock: AiohttpClientMocker, freezer: FrozenDateTimeFactory, snapshot: SnapshotAssertion, - caplog: pytest.LogCaptureFixture, ) -> None: """Test download support package when async_get_loaded_integration fails.""" - # Exclude setup logs with nondeterministic timestamps in verbose runs. - caplog.set_level(logging.INFO, logger="hass_nabucasa.events.bus") - aioclient_mock.get("https://cloud.bla.com/status", text="") aioclient_mock.get( "https://cert-server/directory", exc=Exception("Unexpected exception")