51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
"""
|
|
Test script to verify imports work correctly.
|
|
This can be run both locally and in the container to verify the setup.
|
|
"""
|
|
import os
|
|
import sys
|
|
|
|
# Print current working directory
|
|
print(f"Current working directory: {os.getcwd()}")
|
|
|
|
# Print Python path
|
|
print(f"Python path: {sys.path}")
|
|
|
|
# Try to import the app modules
|
|
try:
|
|
# Add current directory to path
|
|
sys.path.insert(0, os.getcwd())
|
|
|
|
# Try importing the models
|
|
from app.models import Todo
|
|
print(f"Successfully imported Todo from app.models: {Todo}")
|
|
|
|
from app.core.database import Base
|
|
print(f"Successfully imported Base from app.core.database: {Base}")
|
|
|
|
print("All imports succeeded!")
|
|
except Exception as e:
|
|
print(f"Error importing modules: {e}")
|
|
|
|
# Try a different approach for containerized environments
|
|
try:
|
|
# Try to execute the find_modules code
|
|
sys.path.insert(0, os.path.join(os.getcwd(), 'alembic'))
|
|
from find_modules import setup_python_path
|
|
|
|
# Setup paths
|
|
paths = setup_python_path()
|
|
print(f"Updated paths: {paths}")
|
|
|
|
# Try importing again
|
|
from app.models import Todo
|
|
print(f"Successfully imported Todo after path setup: {Todo}")
|
|
|
|
from app.core.database import Base
|
|
print(f"Successfully imported Base after path setup: {Base}")
|
|
|
|
print("Imports succeeded after path setup!")
|
|
except Exception as inner_e:
|
|
print(f"Still failed after path setup: {inner_e}")
|
|
print("This might indicate a deeper issue with the module structure.")
|