python 3.12: utcnow function is deprecated

The following warning is displayed on a system running with Python 3.12:
-------------------
/usr/lib/python3.12/site-packages/ipalib/rpc.py:925: DeprecationWarning:
datetime.utcnow() is deprecated and scheduled for removal in a future
version. Use timezone-aware objects to represent datetimes in UTC:
datetime.now(datetime.UTC).

  timestamp=datetime.datetime.utcnow())
-------------------

Fixes: https://pagure.io/freeipa/issue/9425
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
Alexander Bokovoy authored and Florence Blanc-Renaud committed 2023-08-09 18:31:03 +02:00
1 parent bbb53a1271
commit 09497d2df0
15 files changed
+36 -31

No files matched your search

+1 -1
View File
@@ -402,7 +402,7 @@ class TestHTTPReturn:
assert cookie.http_return_ok(self.url)
def test_expires(self):
now = datetime.datetime.utcnow().replace(microsecond=0)
now = datetime.datetime.now(tz=datetime.UTC).replace(microsecond=0)
# expires 1 day from now
expires = now + datetime.timedelta(days=1)