test: cold-start the stat index before every test (autouse)
#4801 made _rebuild_code's no-change gate read the process-wide stat index, so across the full suite a warm index left by an earlier test (thousands of roots hashed in one process) could serve a stale hash and make a rebuild skip re-extraction - failing watch/reconcile tests nondeterministically depending on ordering. Add an autouse conftest fixture that resets the stat index to its cold init state before each test (#3989: cross-root callers in one process must use a fresh process; a real update/extract always does). Product behavior unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
80b9a4caf4
commit
2b955d3b68
1 file changed
+20
@@ -77,6 +77,26 @@ def _isolate_backend_env(monkeypatch):
|
||||
monkeypatch.delenv(key, raising=False)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _cold_stat_index(monkeypatch):
|
||||
"""Cold-start the module-global stat index before every test.
|
||||
|
||||
The stat index (graphify/cache.py) is a process-wide cache keyed by scan
|
||||
root. Across the full suite thousands of roots are hashed in one process, so
|
||||
a warm index left by an earlier test can serve a stale file hash to the next
|
||||
test's no-change gate and make a rebuild skip re-extraction (#3989, which
|
||||
says library callers crossing roots in one process must use a fresh process
|
||||
per root — a real `graphify update`/extract always does). Resetting to the
|
||||
cold init state makes each test behave like that fresh process."""
|
||||
from graphify import cache
|
||||
|
||||
monkeypatch.setattr(cache, "_stat_index", {}, raising=False)
|
||||
monkeypatch.setattr(cache, "_stat_index_root", None, raising=False)
|
||||
monkeypatch.setattr(cache, "_stat_index_anchor", None, raising=False)
|
||||
monkeypatch.setattr(cache, "_stat_index_path", None, raising=False)
|
||||
monkeypatch.setattr(cache, "_stat_index_dirty", False, raising=False)
|
||||
|
||||
|
||||
_ANALYZE_WARNING_FILTERS = (
|
||||
"ignore:Tensorflow not installed; ParametricUMAP will be unavailable:ImportWarning:umap",
|
||||
"ignore:Please import `random` from the `scipy\\.sparse` namespace.*:"
|
||||
|
||||
Reference in new issue
Block a user