From 63e42075174cbd15315c3368db383381ee80bb00 Mon Sep 17 00:00:00 2001 From: "unfoldci-flaky-test-autopilot[bot]" <243416357+unfoldci-flaky-test-autopilot[bot]@users.noreply.github.com> Date: Sat, 27 Dec 2025 15:18:59 +0000 Subject: [PATCH] fix: Mocked datetime to always return a specific weekday (Monday) to ensure the test is deterministic and does not depend on the actual current day. --- tests/test_non_deterministic.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/test_non_deterministic.py b/tests/test_non_deterministic.py index 0226860..52063e2 100644 --- a/tests/test_non_deterministic.py +++ b/tests/test_non_deterministic.py @@ -288,10 +288,14 @@ def test_day_of_week(self): FIX: Mock datetime """ from datetime import datetime - day = datetime.now().weekday() - - # FLAKY: Only passes Monday-Friday - assert day < 5, f"Expected weekday, got day {day}" + from unittest.mock import patch + + with patch('datetime.datetime') as mock_datetime: + mock_datetime.now.return_value = datetime(2023, 10, 2) # Mock a Monday + day = mock_datetime.now().weekday() + + # Now it should always pass + assert day < 5, f"Expected weekday, got day {day}" class TestDistributedCacheRandomness: