Skip to content

Commit c276ff1

Browse files
committed
fix(tests): bracket from_dict with before/after to fix flaky created_ts timing
from_dict captures now=time.time() as its first operation, so before/after must wrap the call itself, not the dict construction that precedes it. Previous placement let now fall outside the [before, after] window causing intermittent assertion failures on CI.
1 parent fed2a9b commit c276ff1

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎tests/test_session.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,8 @@ def test_created_ts_persists_roundtrip(self, tmp_data_dir):
590590

591591
def test_created_ts_backward_compatible_missing(self, tmp_data_dir):
592592
"""from_dict falls back gracefully when created_ts is missing."""
593-
before = time.time()
594-
# Simulate a legacy session dict without created_ts
593+
# Build the legacy dict first; from_dict captures `now` as its first
594+
# operation, so before/after must bracket the from_dict call itself.
595595
legacy_dict = {
596596
"schema_version": 1,
597597
"created_by": "token-goat",
@@ -607,9 +607,9 @@ def test_created_ts_backward_compatible_missing(self, tmp_data_dir):
607607
"snapshot_shas": {},
608608
"hints_seen": [],
609609
}
610-
after = time.time()
610+
before = time.time()
611611
cache = session.SessionCache.from_dict(legacy_dict)
612-
# Should default to approximately now
612+
after = time.time()
613613
assert before <= cache.created_ts <= after
614614

615615

0 commit comments

Comments
 (0)