From 83b0ec5136a2fd8aae1b5f9d7ec9e0130873a5d3 Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Tue, 6 Jun 2023 16:18:25 +0200 Subject: [PATCH] Freeze time on `timer` tests that assert on remaining time (#94078) --- tests/components/timer/test_init.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/components/timer/test_init.py b/tests/components/timer/test_init.py index 76d92db3702..eabc5e04e0b 100644 --- a/tests/components/timer/test_init.py +++ b/tests/components/timer/test_init.py @@ -265,6 +265,7 @@ async def test_methods_and_events(hass: HomeAssistant) -> None: assert len(results) == expected_events +@pytest.mark.freeze_time("2023-06-05 17:47:50") async def test_start_service(hass: HomeAssistant) -> None: """Test the start/stop service.""" await async_setup_component(hass, DOMAIN, {DOMAIN: {"test1": {CONF_DURATION: 10}}}) @@ -880,6 +881,7 @@ async def test_restore_idle(hass: HomeAssistant) -> None: assert entity.extra_state_attributes[ATTR_RESTORE] +@pytest.mark.freeze_time("2023-06-05 17:47:50") async def test_restore_paused(hass: HomeAssistant) -> None: """Test entity restore logic when timer is paused.""" utc_now = utcnow() @@ -917,6 +919,7 @@ async def test_restore_paused(hass: HomeAssistant) -> None: assert entity.extra_state_attributes[ATTR_RESTORE] +@pytest.mark.freeze_time("2023-06-05 17:47:50") async def test_restore_active_resume(hass: HomeAssistant) -> None: """Test entity restore logic when timer is active and end time is after startup.""" events = async_capture_events(hass, EVENT_TIMER_RESTARTED)