From 3b243d08cdcdd0513aae99a95a032fa723fe39b1 Mon Sep 17 00:00:00 2001 From: Simon Fayer Date: Sat, 25 Jul 2026 19:27:46 +0100 Subject: [PATCH] fix: Minor fixups for TimeUtils tests --- src/DIRAC/Core/Utilities/test/Test_TimeUtilities.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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",