disable caching during tests

This commit is contained in:
Swifty
2025-09-11 10:46:44 +02:00
parent e27e97abf4
commit e8aac204e3
2 changed files with 8 additions and 0 deletions

View File

@@ -8,6 +8,9 @@ from backend.util.logging import configure_logging
load_dotenv()
# Disable caching during tests to avoid test interference
os.environ["DISABLE_CACHE_IN_TESTS"] = "true"
# NOTE: You can run tests like with the --log-cli-level=INFO to see the logs
# Set up logging
configure_logging()

View File

@@ -10,6 +10,7 @@ import functools
import hashlib
import json
import logging
import os
from json import loads
from typing import Any, Callable, Dict, Optional
@@ -141,6 +142,10 @@ def ttl_cache(
def decorator(func: Callable) -> Callable:
@functools.wraps(func)
async def async_wrapper(*args, **kwargs):
# Disable caching during tests to avoid test interference
if os.environ.get("DISABLE_CACHE_IN_TESTS") == "true":
return await func(*args, **kwargs)
# Lazy cache resolution to avoid initialization issues
if cache_instance:
cache = cache_instance