Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

test(rag): isolate image captions from persistent workspace caches

Bingxi Zhao (Frank)8133668d34eb
diff --git a/tests/services/rag/test_llamaindex_document_loader.py b/tests/services/rag/test_llamaindex_document_loader.py
index 6c2908d77..e0fabedcc 100644
--- a/tests/services/rag/test_llamaindex_document_loader.py
+++ b/tests/services/rag/test_llamaindex_document_loader.py
@@ -13,10 +13,23 @@ from __future__ import annotations
import asyncio
from pathlib import Path
import threading
+from types import SimpleNamespace
import pytest
[email protected](autouse=True)
+def isolated_caption_cache(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
+ """Provider stubs must not read or write a persistent workspace cache."""
+ from deeptutor.services.llm import image_caption_cache
+
+ monkeypatch.setattr(
+ image_caption_cache,
+ "get_path_service",
+ lambda: SimpleNamespace(get_parse_cache_root=lambda: tmp_path / "parse_cache"),
+ )
+
+
def _install_stub_parse_service(monkeypatch, results: dict[str, "object"]) -> None:
"""Point ``get_parse_service`` at a stub keyed by source file name.