Verify default timezone is restored when test ends (#116216)

This commit is contained in:
Erik Montnemery 2024-06-26 09:41:16 +02:00 committed by GitHub
parent c085057847
commit 4a86693254
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,6 +5,7 @@ from __future__ import annotations
import asyncio import asyncio
from collections.abc import Callable, Coroutine from collections.abc import Callable, Coroutine
from contextlib import asynccontextmanager, contextmanager from contextlib import asynccontextmanager, contextmanager
import datetime
import functools import functools
import gc import gc
import itertools import itertools
@ -76,7 +77,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.translation import _TranslationsCacheData from homeassistant.helpers.translation import _TranslationsCacheData
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from homeassistant.setup import BASE_PLATFORMS, async_setup_component 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.async_ import create_eager_task
from homeassistant.util.json import json_loads from homeassistant.util.json import json_loads
@ -385,6 +386,13 @@ def verify_cleanup(
"waitpid-" "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) @pytest.fixture(autouse=True)
def reset_hass_threading_local_object() -> Generator[None]: def reset_hass_threading_local_object() -> Generator[None]: