Conversation
The cache tests seed a file's mtime with `pd.Timestamp.timestamp()`, which reads a naive Timestamp as UTC. `load_ohlcv` reads it back through `_cache_is_fresh` with `pd.Timestamp.fromtimestamp()`, which returns local time. The two disagree by the UTC offset, so anywhere west of UTC the seeded file appears to have been written the previous day, `_cache_is_fresh` returns False, and the test's `_fail_download` guard fires. Eight tests fail this way on any machine behind UTC, and none in CI, which runs on ubuntu-latest in UTC. `load_ohlcv` itself is consistent -- both `now` and `written` are local -- so this is a fixture bug, not a behaviour change. Seeding through `datetime.timestamp()`, which reads a naive datetime as local, keeps both sides in the same frame. Verified from UTC-11 (Pacific/Midway) through UTC+14 (Pacific/Kiritimati). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
codify88
pushed a commit
to codify88/TradingAgents
that referenced
this pull request
Sep 18, 2026
… to render The three CliRunner tests in test_cli_mandate_commands.py compare against `result.output` directly, which carries whatever the ambient environment made rich do. Two things leak in, and pytest isolates neither: - Styling, from FORCE_COLOR / COLORTERM / TERM. "Mandate: equity_value" arrives as "\x1b[36mMandate:\x1b[0m equity_value" in a colour-capable shell. NO_COLOR is not enough on its own: it drops colour but keeps rich's bold highlighting on numbers, so a date still arrives as "\x1b[1m2026\x1b[0m-\x1b[1m09\x1b[0m-". - Width. rich wraps to the width detected when the Console was built, at import, so the COLUMNS that CliRunner passes into the invocation arrives too late and the asserted command breaks across lines mid-string. All three passed in CI and failed in an interactive shell. A `plain()` helper strips the escapes and collapses whitespace, so the assertions test content. Verified green across FORCE_COLOR=3, NO_COLOR=1, TERM=dumb, and COLUMNS 30/40, in each case with the rest of the suite. Same class as the two fixes now open upstream as TauricResearch#1367 and TauricResearch#1368: a test that reads its environment rather than isolating from it is green on the machine that wrote it and red on the next one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's wrong
Eight tests in
tests/test_ohlcv_latest_bar.pyandtests/test_ohlcv_cache_freshness.pyfail on any machine whose local timezone isbehind UTC. They pass in CI, which runs
ubuntu-latestin UTC.The fixtures seed a cache file's mtime through pandas:
pd.Timestamp.timestamp()reads a naive Timestamp as UTC. But_cache_is_freshreads the same mtime back withpd.Timestamp.fromtimestamp(), which returns local time:The round trip loses the UTC offset. On
America/New_York:So
load_ohlcvtreats a file it was just handed as written yesterday, refetches,and trips the fixtures'
_fail_downloadguard — surfacing asAssertionError: should use the seeded cache, not downloadandAssertionError: fresh cache must not refetch.Why this is worth taking
It is a test-only fix.
load_ohlcvis already self-consistent: bothnow(
pd.Timestamp.today()) andwritten(fromtimestamp) are local. No productionbehaviour changes, and the freshness rule from #1150 is untouched. The fixtures
were the only thing straddling two time frames.
It removes a false failure that only contributors see. Because CI is UTC, the
suite is green on every PR while being red for any contributor in the Americas
who runs
pytestlocally. That asymmetry is expensive in a way that does notshow up in CI: eight red tests on a first checkout look like a broken repo or a
broken change, and the natural response is to go hunting in
stockstats_utils.py— which is correct — or to stop trusting the local suite. Both cost maintainer
time in triage.
It protects a guard that is meant to be strict. These tests exist to prove
load_ohlcvdoes not hit the network when a same-day cache is present. Rightnow, for a large fraction of contributors, they fail for a reason unrelated to
that property, so a genuine regression in the caching path would be
indistinguishable from the usual local noise.
The fix
Seed the mtime through
datetime.timestamp(), which reads a naive datetime aslocal, so both sides of the comparison are in the same frame. Four call sites, a
comment at each explaining the trap.
Verification
pytest -qon the full suite, and the two affected files across the range:Before the change, all five non-UTC zones fail 8 of those 19.
Reproduced on
2d17df8(v0.5.0).🤖 Generated with Claude Code