Repository navigation
test: make the standalone today() assertion timezone-independent - #390
Conversation
today() lowers to DataFusion's current_date(), which uses the session time zone; ltseq sets none, so it is the UTC date. The test compared it with date.today(), the local date, and failed for part of every day outside UTC. Bracket the query with UTC reads so the check is timezone-independent and survives a UTC midnight rollover mid-query.
AI Code Review — Round 1Reviewed HEAD: FindingsNone. SpecSatisfies issue #249: explicit UTC readings bracket query evaluation, accommodating midnight rollover while retaining checks for exactly four identical dates. Changes are confined to the intended test and its datetime import; production behavior is unchanged. StandardsConsistent with AGENTS.md, CLAUDE.md and repository conventions. The explanatory comment documents the UTC assumption and rollover rationale. No production behavior change requires changelog, docstring or stub updates. AssessmentCorrect, narrowly scoped test-reliability fix. No correctness, security or coverage defects found. ObservationsThe supplied PR snapshot confirms the bound HEAD and base main. All four CI checks were pending in that snapshot; their eventual outcomes are unknown. VerificationRead the issue, PR description, checks, repository guidance, full bound diff and related expression/session code. Ran test_standalone_calls.py under TZ=UTC, TZ=Etc/GMT-14, TZ=Etc/GMT+12 and TZ=America/New_York: 13 passed per zone, 52 total. In-memory clock substitutions exercised both sides of a simulated UTC rollover bracket with real today() queries; both passed. Additional in-memory substitutions confirmed rejection of wrong dates, mixed dates, missing rows and empty results. These simulations did not change the system clock or repository files. git diff --check passed; HEAD remained bound and the final worktree was clean. SummaryNo findings and no further fix round needed. Focused tests passed in all required time zones, and simulated rollover checks support the midnight-race fix. Full CI results remain pending in the supplied snapshot. Needs another fix round: NO |
Why
test_temporal_standalone_takes_no_receivercomparedtoday()withdate.today().today()lowers to DataFusion'scurrent_date(), which uses the session time zone. ltseq sets none, so it returns the UTC date.date.today()returns the local date. Wherever the process's zone is not UTC, the test failed for part of every day. UnderTZ=UTCit could also fail if UTC midnight passed between the query and the Python call. CI runs in UTC, so only local runs hit this, but it cost the #225 acceptance review a manual investigation.Change
The test now reads the UTC date just before and just after the query. It asserts that every row holds the same date and that this date is one of those two readings. This keeps the check pinned to today's behaviour (
today()is the UTC date), because a local-date result still fails whenever the two dates differ. The rollover race is gone because one of the two readings always matches. Production code is unchanged. Whethertoday()should instead follow a local or configurable zone is a separate product question; if that changes, this test changes with it.Setting
TZ=UTCin CI alone was not done: CI already runs in UTC, so it would leave local runs failing and the midnight race in place.Validation
Run at 21:09 UTC on 2026-11-08:
pytest py-ltseq/tests/test_standalone_calls.pypassed (13 of 13) underTZ=UTC,TZ=Etc/GMT-14,TZ=Etc/GMT+12andTZ=America/New_York.main, run at the same moment, failed underTZ=Etc/GMT-14(local date already Nov 9) and passed underTZ=Etc/GMT+12. That confirms the original failure and that the new assertion still tells the UTC date from a local one.The midnight rollover case was not run; it rests on the before/after logic. The full suite was left to CI.
Not covered
test_new_functions.py::test_age_recentbuildsdate.today().replace(year=...+1), which raises on Feb 29, anddt.age()uses the same UTCcurrent_date(). The issue lists it as related but separate, so it is left alone here.Closes #249