Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/DIRAC/Core/Utilities/test/Test_TimeUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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",
Expand Down
Loading