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.
This commit is contained in:
Zenwoh 2026-02-06 13:27:56 +01:00 committed by GitHub
parent d07c87860d
commit eed850ad9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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}"