Freeze timezone in bmw_connected_drive tests (#113533)

Freeze timezone in bmw_connected_drive
This commit is contained in:
Thomas55555 2024-03-15 18:22:17 +01:00 committed by GitHub
parent 066594b25b
commit 66aa2c038a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,8 +1,6 @@
"""Test BMW diagnostics."""
import datetime
import os
import time
import pytest
from syrupy.assertion import SnapshotAssertion
@ -20,7 +18,7 @@ from tests.components.diagnostics import (
from tests.typing import ClientSessionGenerator
@pytest.mark.freeze_time(datetime.datetime(2022, 7, 10, 11))
@pytest.mark.freeze_time(datetime.datetime(2022, 7, 10, 11, tzinfo=datetime.UTC))
async def test_config_entry_diagnostics(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
@ -29,10 +27,6 @@ async def test_config_entry_diagnostics(
) -> None:
"""Test config entry diagnostics."""
# Make sure that local timezone for test is UTC
os.environ["TZ"] = "UTC"
time.tzset()
mock_config_entry = await setup_mocked_integration(hass)
diagnostics = await get_diagnostics_for_config_entry(
@ -42,7 +36,7 @@ async def test_config_entry_diagnostics(
assert diagnostics == snapshot
@pytest.mark.freeze_time(datetime.datetime(2022, 7, 10, 11))
@pytest.mark.freeze_time(datetime.datetime(2022, 7, 10, 11, tzinfo=datetime.UTC))
async def test_device_diagnostics(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
@ -52,10 +46,6 @@ async def test_device_diagnostics(
) -> None:
"""Test device diagnostics."""
# Make sure that local timezone for test is UTC
os.environ["TZ"] = "UTC"
time.tzset()
mock_config_entry = await setup_mocked_integration(hass)
reg_device = device_registry.async_get_device(
@ -70,7 +60,7 @@ async def test_device_diagnostics(
assert diagnostics == snapshot
@pytest.mark.freeze_time(datetime.datetime(2022, 7, 10, 11))
@pytest.mark.freeze_time(datetime.datetime(2022, 7, 10, 11, tzinfo=datetime.UTC))
async def test_device_diagnostics_vehicle_not_found(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
@ -80,10 +70,6 @@ async def test_device_diagnostics_vehicle_not_found(
) -> None:
"""Test device diagnostics when the vehicle cannot be found."""
# Make sure that local timezone for test is UTC
os.environ["TZ"] = "UTC"
time.tzset()
mock_config_entry = await setup_mocked_integration(hass)
reg_device = device_registry.async_get_device(