From 1bf671977f1bf6d0591fe21e3b99a805c25d1bbe Mon Sep 17 00:00:00 2001 From: Josias Montag Date: Mon, 19 Aug 2024 16:00:44 +0200 Subject: [PATCH] wip --- tests/test_binary_sensor.py | 12 ++++++++++++ tests/test_sensor.py | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/tests/test_binary_sensor.py b/tests/test_binary_sensor.py index e416f3d..3b44461 100644 --- a/tests/test_binary_sensor.py +++ b/tests/test_binary_sensor.py @@ -1,5 +1,6 @@ """Test binary sensor for DWD rain radar integration.""" import os +import time import pytest from unittest.mock import AsyncMock, patch, MagicMock @@ -24,6 +25,17 @@ def entity_registry_enabled_by_default() -> Generator[None]: ): yield +@pytest.fixture(autouse=True) +def set_timezone(): + os.environ['TZ'] = 'Europe/Berlin' # Set to your desired timezone + time.tzset() # Apply the timezone setting + + yield # Run the test + + # Cleanup after the test + del os.environ['TZ'] + time.tzset() + @pytest.mark.asyncio @patch('httpx.AsyncClient.get', new_callable=AsyncMock) @freeze_time("2024-08-08T15:47:00", tz_offset=2) diff --git a/tests/test_sensor.py b/tests/test_sensor.py index 1860161..b5076d0 100644 --- a/tests/test_sensor.py +++ b/tests/test_sensor.py @@ -1,5 +1,6 @@ """Test sensor for DWD rain radar integration.""" import os +import time import pytest from unittest.mock import AsyncMock, patch, MagicMock @@ -24,6 +25,17 @@ def entity_registry_enabled_by_default() -> Generator[None]: ): yield +@pytest.fixture(autouse=True) +def set_timezone(): + os.environ['TZ'] = 'Europe/Berlin' # Set to your desired timezone + time.tzset() # Apply the timezone setting + + yield # Run the test + + # Cleanup after the test + del os.environ['TZ'] + time.tzset() + @pytest.mark.asyncio @patch('httpx.AsyncClient.get', new_callable=AsyncMock) @freeze_time("2024-08-08T15:47:00", tz_offset=2)