diff --git a/tests/components/calendar/test_trigger.py b/tests/components/calendar/test_trigger.py index 98a21db8ef7..24b4b06b493 100644 --- a/tests/components/calendar/test_trigger.py +++ b/tests/components/calendar/test_trigger.py @@ -105,6 +105,15 @@ class FakeSchedule: async def fire_until(self, end: datetime.timedelta) -> None: """Simulate the passage of time by firing alarms until the time is reached.""" + + current_time = dt_util.as_utc(self.freezer()) + if (end - current_time) > (TEST_UPDATE_INTERVAL * 2): + # Jump ahead to right before the target alarm them to remove + # unnecessary waiting, before advancing in smaller increments below. + # This leaves time for multiple update intervals to refresh the set + # of upcoming events + await self.fire_time(end - TEST_UPDATE_INTERVAL * 2) + while dt_util.utcnow() < end: self.freezer.tick(TEST_TIME_ADVANCE_INTERVAL) await self.fire_time(dt_util.utcnow())