feat(add cache dir):

This commit is contained in:
Alexander Myasoedov
2025-12-09 19:51:47 +02:00
parent 9a4fb05491
commit b9dc5de708
9 changed files with 110 additions and 14 deletions
+13 -3
View File
@@ -1,12 +1,17 @@
import os
import warnings
from pathlib import Path
import pytest
from cache_to_disk import delete_old_disk_caches
from sklearn.exceptions import InconsistentVersionWarning
from agentic_security.cache_config import ensure_cache_dir
from agentic_security.logutils import logger
CACHE_DIR = ensure_cache_dir(Path(__file__).parent / ".cache_to_disk")
from cache_to_disk import delete_old_disk_caches # noqa: E402 # isort: skip
# Silence noisy third-party warnings that do not impact test behavior
warnings.filterwarnings("ignore", category=InconsistentVersionWarning)
try:
@@ -29,5 +34,10 @@ def pytest_runtest_setup(item):
@pytest.fixture(autouse=True, scope="session")
def setup_delete_old_disk_caches():
logger.info("delete_old_disk_caches")
delete_old_disk_caches()
logger.info("delete_old_disk_caches at %s", CACHE_DIR)
try:
delete_old_disk_caches()
except PermissionError:
logger.warning("Skipping cache cleanup due to permissions for %s", CACHE_DIR)
except OSError as exc:
logger.warning("Skipping cache cleanup due to OS error: %s", exc)