Fix consider-using-with pylint warnings in matrix tests (#119365)

This commit is contained in:
epenet 2024-06-11 15:06:44 +02:00 committed by GitHub
parent 2e9f63ced6
commit e14146d7c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -24,6 +24,7 @@ from nio import (
)
from PIL import Image
import pytest
from typing_extensions import Generator
from homeassistant.components.matrix import (
CONF_COMMANDS,
@ -305,9 +306,9 @@ def command_events(hass: HomeAssistant):
@pytest.fixture
def image_path(tmp_path: Path):
def image_path(tmp_path: Path) -> Generator[tempfile._TemporaryFileWrapper]:
"""Provide the Path to a mock image."""
image = Image.new("RGBA", size=(50, 50), color=(256, 0, 0))
image_file = tempfile.NamedTemporaryFile(dir=tmp_path)
image.save(image_file, "PNG")
return image_file
with tempfile.NamedTemporaryFile(dir=tmp_path) as image_file:
image.save(image_file, "PNG")
yield image_file