Files
Jyotisha/tests/test_vedastro_executor_isolation_20261028.py
T
jesseandClaude Opus 5.5 537beb2934
Independent Staging Quality Gate / validate (push) Successful in 16m7s
Independent Staging Quality Gate / publish (push) Successful in 4m22s
test: each test gets its own foreground VedAstro pool, drained at teardown (BUG-1498)
A task left running wrote its outcome into the next test's cache directory,
so the next test saw a remembered failure and never called the gateway.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 19:39:28 +08:00

33 lines
1.0 KiB
Python

"""BUG-1498: a foreground VedAstro task never outlives the test that started it.
The two tests run in file order. The first leaves a slow task on the foreground
executor; the second checks that the task finished before it began, so it could
not write into the second test's cache directory.
"""
from __future__ import annotations
import os
import time
from scripts import vedastro_foreground as foreground
_SEEN: list[str] = []
def _slow_task() -> None:
time.sleep(0.3)
_SEEN.append(os.environ.get("JYOTISH_VEDASTRO_SNAPSHOT_NEGATIVE_CACHE_DIR", ""))
def test_a_leaves_slow_work_on_the_foreground_executor() -> None:
_SEEN.clear()
foreground._FOREGROUND_VEDASTRO_EXECUTOR.submit(_slow_task)
def test_b_does_not_see_the_previous_tests_work() -> None:
mine = os.environ["JYOTISH_VEDASTRO_SNAPSHOT_NEGATIVE_CACHE_DIR"]
assert len(_SEEN) == 1, "the earlier test's task finished during its own teardown"
time.sleep(0.5)
assert mine not in _SEEN, "a leftover task wrote into this test's cache directory"