mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Simplify time zone setting in tests (#68330)
* Simplify timezone setting in tests * Fix typo * Adjust caldav tests * Adjust input_datetime tests * Adjust time_date tests * Adjust tod tests * Adjust helper tests * Adjust recorder tests * Adjust risco tests * Adjust aemet tests * Adjust flux tests * Adjust forecast_solar tests * Revert unnecessary change in forecast_solar test * Adjust climacell tests * Adjust google tests * Adjust sensor tests * Adjust sonarr tests * Adjust template tests * Adjust zodiac tests Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
@@ -28,8 +28,6 @@ import homeassistant.util.dt as dt_util
|
||||
|
||||
from tests.common import async_mock_service
|
||||
|
||||
ORIG_TIME_ZONE = dt_util.DEFAULT_TIME_ZONE
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def calls(hass):
|
||||
@@ -46,14 +44,6 @@ def setup_comp(hass):
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def teardown():
|
||||
"""Restore."""
|
||||
yield
|
||||
|
||||
dt_util.set_default_time_zone(ORIG_TIME_ZONE)
|
||||
|
||||
|
||||
def assert_element(trace_element, expected_element, path):
|
||||
"""Assert a trace element is as expected.
|
||||
|
||||
@@ -2659,8 +2649,7 @@ async def test_if_action_before_sunrise_no_offset_kotzebue(hass, hass_ws_client,
|
||||
at 7 AM and sunset at 3AM during summer
|
||||
After sunrise is true from sunrise until midnight, local time.
|
||||
"""
|
||||
tz = dt_util.get_time_zone("America/Anchorage")
|
||||
dt_util.set_default_time_zone(tz)
|
||||
hass.config.set_time_zone("America/Anchorage")
|
||||
hass.config.latitude = 66.5
|
||||
hass.config.longitude = 162.4
|
||||
await async_setup_component(
|
||||
@@ -2736,8 +2725,7 @@ async def test_if_action_after_sunrise_no_offset_kotzebue(hass, hass_ws_client,
|
||||
at 7 AM and sunset at 3AM during summer
|
||||
Before sunrise is true from midnight until sunrise, local time.
|
||||
"""
|
||||
tz = dt_util.get_time_zone("America/Anchorage")
|
||||
dt_util.set_default_time_zone(tz)
|
||||
hass.config.set_time_zone("America/Anchorage")
|
||||
hass.config.latitude = 66.5
|
||||
hass.config.longitude = 162.4
|
||||
await async_setup_component(
|
||||
@@ -2813,8 +2801,7 @@ async def test_if_action_before_sunset_no_offset_kotzebue(hass, hass_ws_client,
|
||||
at 7 AM and sunset at 3AM during summer
|
||||
Before sunset is true from midnight until sunset, local time.
|
||||
"""
|
||||
tz = dt_util.get_time_zone("America/Anchorage")
|
||||
dt_util.set_default_time_zone(tz)
|
||||
hass.config.set_time_zone("America/Anchorage")
|
||||
hass.config.latitude = 66.5
|
||||
hass.config.longitude = 162.4
|
||||
await async_setup_component(
|
||||
@@ -2890,8 +2877,7 @@ async def test_if_action_after_sunset_no_offset_kotzebue(hass, hass_ws_client, c
|
||||
at 7 AM and sunset at 3AM during summer
|
||||
After sunset is true from sunset until midnight, local time.
|
||||
"""
|
||||
tz = dt_util.get_time_zone("America/Anchorage")
|
||||
dt_util.set_default_time_zone(tz)
|
||||
hass.config.set_time_zone("America/Anchorage")
|
||||
hass.config.latitude = 66.5
|
||||
hass.config.longitude = 162.4
|
||||
await async_setup_component(
|
||||
|
||||
Reference in New Issue
Block a user