# backend/test_auth_init.py # Purpose: Directly test the core logic of myapp/auth/__init__.py import sys import os import traceback print("--- Starting test_auth_init.py ---") # --- Setup Path --- # Get the absolute path of the directory containing this script (backend/) current_dir = os.path.dirname(os.path.abspath(__file__)) # Get the project root directory (SurfSmart/) project_root = os.path.dirname(current_dir) # Add project root to sys.path to allow 'import backend.myapp.auth' later if needed # and potentially allow flask.Blueprint to resolve correctly if there are path issues. if project_root not in sys.path: sys.path.insert(0, project_root) print(f"Test script added project root: {project_root}") print(f"Test script current sys.path: {sys.path}") print(f"Test script current working directory: {os.getcwd()}") # --- Test Core Logic --- bp_instance = None # Initialize to None try: print("\nAttempting: from flask import Blueprint") from flask import Blueprint print("Successfully imported Blueprint") print("\nAttempting: bp = Blueprint('auth', __name__, url_prefix='/api/auth')") # Use a different variable name just in case 'bp' has weird conflicts test_bp = Blueprint('auth', __name__, url_prefix='/api/auth') bp_instance = test_bp # Assign to check later print(f"Successfully instantiated Blueprint: {test_bp}") print(f"Type of test_bp: {type(test_bp)}") except ImportError as e: print(f"\nERROR during import: {e}") traceback.print_exc() except Exception as e: print(f"\nUNEXPECTED ERROR during instantiation: {e}") traceback.print_exc() # --- Final Check --- print("\n--- Final Check ---") if bp_instance is not None: print(f"Variable 'bp_instance' was assigned successfully: {bp_instance}") else: print("Variable 'bp_instance' was NOT assigned (likely due to error above).") print("--- Finished test_auth_init.py ---")