@@ -307,7 +307,7 @@ def test_datetime_past(py_and_json: PyAndJson, input_value, expected):
307
307
308
308
def test_datetime_past_timezone ():
309
309
v = SchemaValidator (core_schema .datetime_schema (now_utc_offset = 0 , now_op = 'past' ))
310
- now_utc = datetime .utcnow (). replace ( tzinfo = timezone .utc ) - timedelta (seconds = 1 )
310
+ now_utc = datetime .now ( timezone .utc ) - timedelta (seconds = 1 )
311
311
assert v .isinstance_python (now_utc )
312
312
# "later" in the day
313
313
assert v .isinstance_python (now_utc .astimezone (pytz .timezone ('Europe/Istanbul' )))
@@ -350,7 +350,7 @@ def test_datetime_future(py_and_json: PyAndJson, input_value, expected):
350
350
351
351
def test_datetime_future_timezone ():
352
352
v = SchemaValidator (core_schema .datetime_schema (now_utc_offset = 0 , now_op = 'future' ))
353
- now_utc = datetime .utcnow (). replace ( tzinfo = timezone .utc )
353
+ now_utc = datetime .now ( timezone .utc )
354
354
355
355
soon_utc = now_utc + timedelta (minutes = 1 )
356
356
assert v .isinstance_python (soon_utc )
@@ -376,10 +376,10 @@ def test_mock_utc_offset_8_hours(mocker):
376
376
"""
377
377
mocker .patch ('time.localtime' , return_value = type ('time.struct_time' , (), {'tm_gmtoff' : 8 * 60 * 60 }))
378
378
v = SchemaValidator (core_schema .datetime_schema (now_op = 'future' ))
379
- future = datetime .utcnow ( ) + timedelta (hours = 8 , minutes = 1 )
379
+ future = datetime .now ( timezone . utc ). replace ( tzinfo = None ) + timedelta (hours = 8 , minutes = 1 )
380
380
assert v .isinstance_python (future )
381
381
382
- future = datetime .utcnow ( ) + timedelta (hours = 7 , minutes = 59 )
382
+ future = datetime .now ( timezone . utc ). replace ( tzinfo = None ) + timedelta (hours = 7 , minutes = 59 )
383
383
assert not v .isinstance_python (future )
384
384
385
385
0 commit comments