Skip to content

Commit 1252ab9

Browse files
committed
redis test passing
1 parent 89d6f28 commit 1252ab9

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

backend/test_redis.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
import os
2+
import logging
3+
import time
4+
5+
# Set Django settings module before importing Django-related modules
26
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
37

8+
# Load environment variables
9+
from dotenv import load_dotenv
10+
# Load environment variables from .env.local
11+
load_dotenv(os.path.join(os.path.dirname(os.path.dirname(__file__)), '.env.local'))
12+
13+
# Django setup
414
import django
515
django.setup()
616

17+
# Import Django and Redis modules after Django setup
718
import redis
819
from django.conf import settings
9-
import time
10-
import logging
11-
from dotenv import load_dotenv
12-
13-
# Load environment variables from .env.local
14-
load_dotenv(os.path.join(os.path.dirname(os.path.dirname(__file__)), '.env.local'))
20+
from django.core.cache import cache
1521

1622
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
1723
logger = logging.getLogger(__name__)
@@ -143,7 +149,6 @@ def test_django_cache():
143149

144150
try:
145151
# Try to import the cache module
146-
from django.core.cache import cache
147152
logger.info(f"Django cache backend: {cache.__class__.__name__}")
148153

149154
logger.info("Testing Django cache framework")

0 commit comments

Comments
 (0)