Fix RuntimeWarning in rest tests (#146452)

This commit is contained in:
Marc Mueller
2025-06-10 15:26:07 +02:00
committed by GitHub
parent f448f488ba
commit 6c5f7eabff
2 changed files with 18 additions and 16 deletions

View File

@ -2,7 +2,7 @@
from http import HTTPStatus
import ssl
from unittest.mock import AsyncMock, MagicMock, patch
from unittest.mock import patch
import pytest
@ -174,11 +174,12 @@ async def test_setup_ssl_ciphers(
hass: HomeAssistant,
ssl_cipher_list: str,
ssl_cipher_list_expected: SSLCipherList,
aioclient_mock: AiohttpClientMocker,
) -> None:
"""Test setup with minimum configuration."""
with patch(
"homeassistant.components.rest.data.async_get_clientsession",
return_value=MagicMock(request=AsyncMock(return_value=MagicMock())),
return_value=aioclient_mock,
) as aiohttp_client:
assert await async_setup_component(
hass,

View File

@ -63,6 +63,7 @@ class AiohttpClientMocker:
cookies=None,
side_effect=None,
closing=None,
timeout=None,
):
"""Mock a request."""
if not isinstance(url, RETYPE):
@ -70,21 +71,21 @@ class AiohttpClientMocker:
if params:
url = url.with_query(params)
self._mocks.append(
AiohttpClientMockResponse(
method=method,
url=url,
status=status,
response=content,
json=json,
text=text,
cookies=cookies,
exc=exc,
headers=headers,
side_effect=side_effect,
closing=closing,
)
resp = AiohttpClientMockResponse(
method=method,
url=url,
status=status,
response=content,
json=json,
text=text,
cookies=cookies,
exc=exc,
headers=headers,
side_effect=side_effect,
closing=closing,
)
self._mocks.append(resp)
return resp
def get(self, *args, **kwargs):
"""Register a mock get request."""