1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Add typing to tests with single hass argument (#87631)

This commit is contained in:
epenet
2023-02-07 15:01:16 +01:00
committed by GitHub
parent fe9f6823c3
commit 59ca7780fa
33 changed files with 104 additions and 75 deletions

View File

@@ -8,12 +8,13 @@ from homeassistant.const import (
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.temperature import display_temp
TEMP = 24.636626
def test_temperature_not_a_number(hass):
def test_temperature_not_a_number(hass: HomeAssistant) -> None:
"""Test that temperature is a number."""
temp = "Temperature"
with pytest.raises(Exception) as exception:
@@ -22,16 +23,16 @@ def test_temperature_not_a_number(hass):
assert f"Temperature is not a number: {temp}" in str(exception.value)
def test_celsius_halves(hass):
def test_celsius_halves(hass: HomeAssistant) -> None:
"""Test temperature to celsius rounding to halves."""
assert display_temp(hass, TEMP, TEMP_CELSIUS, PRECISION_HALVES) == 24.5
def test_celsius_tenths(hass):
def test_celsius_tenths(hass: HomeAssistant) -> None:
"""Test temperature to celsius rounding to tenths."""
assert display_temp(hass, TEMP, TEMP_CELSIUS, PRECISION_TENTHS) == 24.6
def test_fahrenheit_wholes(hass):
def test_fahrenheit_wholes(hass: HomeAssistant) -> None:
"""Test temperature to fahrenheit rounding to wholes."""
assert display_temp(hass, TEMP, TEMP_FAHRENHEIT, PRECISION_WHOLE) == -4