From eed850ad9b89b8b266ee098a24ef51fbe79582e7 Mon Sep 17 00:00:00 2001 From: Zenwoh Date: Fri, 6 Feb 2026 13:27:56 +0100 Subject: [PATCH] Fix expiration time assertion in key management tests Adjust expiration time assertions to account for microsecond precision. This test usually fails by 500 ms max for me in February, hence the proposed change. --- .../management_endpoints/test_key_management_endpoints.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py b/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py index 5720ff948a6..742fc7bf865 100644 --- a/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py +++ b/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py @@ -368,6 +368,12 @@ async def test_budget_reset_and_expires_at_first_of_month(monkeypatch): # Allow for some variance due to test execution time (subtract 1 second buffer for timing) expected_expires_min = now + timedelta(days=28, seconds=-1) expected_expires_max = now + timedelta(days=32) + + # Remove ms precision as it can cause issues with the assertion due to small differences in execution time + expires = expires.replace(microsecond=0) + expected_expires_min = expected_expires_min.replace(microsecond=0) + expected_expires_max = expected_expires_max.replace(microsecond=0) + assert ( expected_expires_min <= expires <= expected_expires_max ), f"Expected expires to be approximately 1 month from now, got {expires}"