From 4fae7dbccd8564d046179eb2cf931e716ace414a Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Fri, 21 Feb 2025 20:59:32 +0000 Subject: [PATCH] Avoid using datetime.fromtimestamp It is incompatible with freezegun because of a freezegun bug: https://github.com/spulec/freezegun/pull/567/files --- src/mock_vws/_query_validators/date_validators.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mock_vws/_query_validators/date_validators.py b/src/mock_vws/_query_validators/date_validators.py index d02e44aaa..4048238c9 100644 --- a/src/mock_vws/_query_validators/date_validators.py +++ b/src/mock_vws/_query_validators/date_validators.py @@ -88,14 +88,16 @@ def validate_date_in_range(*, request_headers: Mapping[str, str]) -> None: date_header = request_headers["Date"] gmt = ZoneInfo(key="GMT") - date = datetime.datetime.fromtimestamp(timestamp=0, tz=gmt) + dates: list[datetime.datetime] = [] for date_format in _accepted_date_formats(): with contextlib.suppress(ValueError): date = datetime.datetime.strptime( date_header, date_format, ).astimezone() + dates.append(date) + date = dates[0] now = datetime.datetime.now(tz=gmt) date_from_header = date.replace(tzinfo=gmt) time_difference = now - date_from_header