Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions libs/uniharness/tests/unit_tests/harness/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ async def test_datetime_with_timezone(self) -> None:
assert env.today_date == datetime(2026, 3, 13, 10, 30, 0, tzinfo=UTC)

async def test_datetime_without_timezone_fallback(self) -> None:
"""Falls back to naive datetime when timezone offset is missing."""
"""Falls back to UTC when timezone offset cannot be parsed."""
computer = _mock_computer(_make_stdout(date="2026-03-13T10:30:00"))
env = await EnvironmentResolver(computer).resolve()

assert env.today_date.year == 2026
assert env.today_date.tzinfo is None
assert env.today_date.tzinfo is not None

async def test_empty_datetime_raises(self) -> None:
computer = _mock_computer(_make_stdout(date=""))
Expand Down
4 changes: 2 additions & 2 deletions libs/uniharness/uniharness/harness/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from __future__ import annotations

from datetime import datetime
from datetime import UTC, datetime
from typing import TYPE_CHECKING

from uniharness.types import EnvironmentContext
Expand Down Expand Up @@ -78,7 +78,7 @@ async def resolve(self) -> EnvironmentContext:
try:
now = datetime.strptime(raw_dt, "%Y-%m-%dT%H:%M:%S%z")
except ValueError:
now = datetime.strptime(raw_dt[:19], "%Y-%m-%dT%H:%M:%S") # noqa: DTZ007
now = datetime.strptime(raw_dt[:19], "%Y-%m-%dT%H:%M:%S").replace(tzinfo=UTC)

return EnvironmentContext(
working_dir=values[0],
Expand Down