From cac2f9d8abf9d27ff32a5268a6746058c0387b63 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 18 Nov 2024 22:16:49 -0500 Subject: [PATCH] maint: stop using deprecated utcnow Potentially it might be addressing - https://github.com/gabrielfalcao/HTTPretty/issues/474 In our case we got datalad tests failing since we trigger errors on all new deprecation warnigns and this was the one this time .pybuild/cpython3_3.12_datalad/build/datalad/downloaders/tests/test_http.py: 13 warnings /usr/lib/python3/dist-packages/httpretty/core.py:1077: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC). now = datetime.utcnow() --- httpretty/core.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/httpretty/core.py b/httpretty/core.py index d6843e7c..48c5909c 100644 --- a/httpretty/core.py +++ b/httpretty/core.py @@ -68,8 +68,7 @@ from .errors import HTTPrettyError, UnmockedError -from datetime import datetime -from datetime import timedelta +from datetime import (datetime, timedelta, UTC) from errno import EAGAIN old_socket = socket.socket @@ -611,7 +610,7 @@ def normalize_headers(self, headers): return new def fill_filekind(self, fk): - now = datetime.utcnow() + now = datetime.now(UTC) headers = { 'status': self.status,