1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 04:50:05 +00:00

Add missing hass type in tests/helpers (#124039)

This commit is contained in:
epenet
2024-08-16 17:09:12 +02:00
committed by GitHub
parent 2cd4456762
commit 56b4a7f291
8 changed files with 146 additions and 61 deletions

View File

@@ -1,9 +1,11 @@
"""Test singleton helper."""
from typing import Any
from unittest.mock import Mock
import pytest
from homeassistant.core import HomeAssistant
from homeassistant.helpers import singleton
@@ -14,11 +16,11 @@ def mock_hass():
@pytest.mark.parametrize("result", [object(), {}, []])
async def test_singleton_async(mock_hass, result) -> None:
async def test_singleton_async(mock_hass: HomeAssistant, result: Any) -> None:
"""Test singleton with async function."""
@singleton.singleton("test_key")
async def something(hass):
async def something(hass: HomeAssistant) -> Any:
return result
result1 = await something(mock_hass)
@@ -30,11 +32,11 @@ async def test_singleton_async(mock_hass, result) -> None:
@pytest.mark.parametrize("result", [object(), {}, []])
def test_singleton(mock_hass, result) -> None:
def test_singleton(mock_hass: HomeAssistant, result: Any) -> None:
"""Test singleton with function."""
@singleton.singleton("test_key")
def something(hass):
def something(hass: HomeAssistant) -> Any:
return result
result1 = something(mock_hass)