Fix generic IP camera tests affecting other tests (#122858)

This commit is contained in:
Erik Montnemery 2024-07-30 16:29:59 +02:00 committed by GitHub
parent b973455037
commit 1382f7a3dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 4 deletions

View file

@ -2,6 +2,7 @@
from __future__ import annotations
from collections.abc import Generator
from io import BytesIO
from unittest.mock import AsyncMock, MagicMock, Mock, _patch, patch
@ -51,15 +52,23 @@ def fakeimgbytes_gif() -> bytes:
@pytest.fixture
def fakeimg_png(fakeimgbytes_png: bytes) -> None:
def fakeimg_png(fakeimgbytes_png: bytes) -> Generator[None]:
"""Set up respx to respond to test url with fake image bytes."""
respx.get("http://127.0.0.1/testurl/1").respond(stream=fakeimgbytes_png)
respx.get("http://127.0.0.1/testurl/1", name="fake_img").respond(
stream=fakeimgbytes_png
)
yield
respx.pop("fake_img")
@pytest.fixture
def fakeimg_gif(fakeimgbytes_gif: bytes) -> None:
def fakeimg_gif(fakeimgbytes_gif: bytes) -> Generator[None]:
"""Set up respx to respond to test url with fake image bytes."""
respx.get("http://127.0.0.1/testurl/1").respond(stream=fakeimgbytes_gif)
respx.get("http://127.0.0.1/testurl/1", name="fake_img").respond(
stream=fakeimgbytes_gif
)
yield
respx.pop("fake_img")
@pytest.fixture(scope="package")

View file

@ -638,6 +638,7 @@ async def test_form_stream_other_error(hass: HomeAssistant, user_flow) -> None:
@respx.mock
@pytest.mark.usefixtures("fakeimg_png")
async def test_form_stream_worker_error(
hass: HomeAssistant, user_flow: ConfigFlowResult
) -> None: