diff --git a/tests/conftest.py b/tests/conftest.py index 1d4699647c9..161ff458ac0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,6 +5,7 @@ from __future__ import annotations import asyncio from collections.abc import Callable, Coroutine from contextlib import asynccontextmanager, contextmanager +import datetime import functools import gc import itertools @@ -76,7 +77,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.translation import _TranslationsCacheData from homeassistant.helpers.typing import ConfigType from homeassistant.setup import BASE_PLATFORMS, async_setup_component -from homeassistant.util import location +from homeassistant.util import dt as dt_util, location from homeassistant.util.async_ import create_eager_task from homeassistant.util.json import json_loads @@ -385,6 +386,13 @@ def verify_cleanup( "waitpid-" ) + try: + # Verify the default time zone has been restored + assert dt_util.DEFAULT_TIME_ZONE is datetime.UTC + finally: + # Restore the default time zone to not break subsequent tests + dt_util.DEFAULT_TIME_ZONE = datetime.UTC + @pytest.fixture(autouse=True) def reset_hass_threading_local_object() -> Generator[None]: