Skip to content

Commit df0ce3b

Browse files
authored
Resolve datetime.datetime.utcnow() deprecation (#3751)
Co-authored-by: Marcello Dalponte <[email protected]>
1 parent 087c99d commit df0ce3b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

newsfragments/3751.internal.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Resolve the DeprecationWarning for the usage of `datetime.datetime.utcnow()`

tests/core/utilities/test_encoding.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,11 @@ def test_text_if_str_on_text(val):
144144
),
145145
(
146146
{
147-
"date": [datetime.datetime.utcnow(), datetime.datetime.now()],
148-
"other_date": datetime.datetime.utcnow().date(),
147+
"date": [
148+
datetime.datetime.now(datetime.timezone.utc),
149+
datetime.datetime.now(),
150+
],
151+
"other_date": datetime.datetime.now(datetime.timezone.utc).date(),
149152
},
150153
TypeError,
151154
"Could not encode to JSON: .*'other_date'.*is not JSON serializable",

0 commit comments

Comments
 (0)