diff --git a/src/DIRAC/Core/Utilities/test/Test_TimeUtilities.py b/src/DIRAC/Core/Utilities/test/Test_TimeUtilities.py index 5fbaff9d365..3d08c8d02ce 100644 --- a/src/DIRAC/Core/Utilities/test/Test_TimeUtilities.py +++ b/src/DIRAC/Core/Utilities/test/Test_TimeUtilities.py @@ -33,9 +33,9 @@ def test_returns_naive_datetime(self): assert dt.tzinfo is None, "utcnow() must strip tzinfo and return naive" def test_is_roughly_now(self): - before = datetime.datetime.utcnow() + before = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) dt = DiracTime.utcnow() - after = datetime.datetime.utcnow() + after = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) assert before <= dt <= after + datetime.timedelta(seconds=2) def test_return_type_is_datetime_not_date(self): @@ -73,7 +73,7 @@ def test_known_epochs(self, epoch): """utcfromtimestamp produces a naive UTC datetime whose timestamp round-trips.""" dt = DiracTime.utcfromtimestamp(epoch) assert dt.tzinfo is None - assert dt.timestamp() == epoch + assert dt.replace(tzinfo=datetime.timezone.utc).timestamp() == epoch @pytest.mark.parametrize( "epoch",