Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

remove debug statements

ScottVRd0c94918ec28
diff --git a/tests/conftest.py b/tests/conftest.py
index 6b6bd68820..729e89792d 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -9,10 +9,7 @@ import os # Import os for additional path debugging
# Add debug messages for path setup
current_file_path = Path(__file__).resolve()
project_root = current_file_path.parent.parent
-print(f"DEBUG: conftest.py path: {current_file_path}")
-print(f"DEBUG: Calculated project root: {project_root}")
sys.path.append(str(project_root))
-print(f"DEBUG: sys.path after appending project root: {sys.path}")
from src.local_deep_research.web.database.models import Base, Setting, SettingType
@@ -25,23 +22,18 @@ def setup_database_for_all_tests(tmp_path_factory, session_mocker): # Directly u
Provides a database setup for a temporary SQLite file database for the entire test session.
It patches db_utils.get_db_session and db_utils.get_settings_manager to use this test DB.
"""
- print("\nDEBUG: Entering setup_database_for_all_tests fixture.")
# Call cache_clear on the functions from db_utils_module.
# This ensures any pre-existing cached instances are gone.
# We must ensure db_utils_module is imported before this point.
try:
- print("DEBUG: Performing aggressive cache clear on db_utils functions.")
if hasattr(db_utils_module.get_db_session, 'cache_clear'):
db_utils_module.get_db_session.cache_clear()
- print("DEBUG: db_utils_module.get_db_session cache cleared.")
if hasattr(db_utils_module.get_settings_manager, 'cache_clear'):
db_utils_module.get_settings_manager.cache_clear()
- print("DEBUG: db_utils_module.get_settings_manager cache cleared.")
if hasattr(db_utils_module.get_db_setting, 'cache_clear'):
db_utils_module.get_db_setting.cache_clear() # Clear get_db_setting's cache too
- print("DEBUG: db_utils_module.get_db_setting cache cleared.")
except Exception as e:
print(f"ERROR: Failed to clear db_utils caches aggressively: {e}")
@@ -53,29 +45,19 @@ def setup_database_for_all_tests(tmp_path_factory, session_mocker): # Directly u
db_file = temp_dir / "test_settings.db"
db_url = f"sqlite:///{db_file}"
- print(f"DEBUG: Temporary directory created by tmp_path_factory: {temp_dir}")
- print(f"DEBUG: Database file path: {db_file}")
- print(f"DEBUG: Database URL: {db_url}")
-
# Check if the directory is writable
if not os.access(temp_dir, os.W_OK):
print(f"ERROR: Temporary directory {temp_dir} is not writable!")
- else:
- print(f"DEBUG: Temporary directory {temp_dir} is writable.")
engine = None
try:
- print("DEBUG: Attempting to create SQLAlchemy engine.")
engine = create_engine(db_url)
- print("DEBUG: SQLAlchemy engine created successfully.")
except Exception as e:
print(f"ERROR: Failed to create SQLAlchemy engine: {e}")
raise
try:
- print("DEBUG: Attempting to create database tables (Base.metadata.create_all).")
Base.metadata.create_all(engine)
- print("DEBUG: Database tables created successfully.")
except SQLAlchemyError as e:
print(f"ERROR: SQLAlchemyError during Base.metadata.create_all: {e}")
raise
@@ -84,14 +66,11 @@ def setup_database_for_all_tests(tmp_path_factory, session_mocker): # Directly u
raise
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
- print("DEBUG: SessionLocal sessionmaker created.")
temp_session = SessionLocal()
temp_settings_manager = SettingsManager(db_session=temp_session)
try:
- print("DEBUG: Loading default settings into the test database.")
temp_settings_manager.load_from_defaults_file(commit=True)
- print("DEBUG: Default settings loaded successfully.")
except Exception as e:
print(f"ERROR: Failed to load default settings: {e}")
temp_session.rollback() # Rollback if default loading fails
@@ -100,40 +79,26 @@ def setup_database_for_all_tests(tmp_path_factory, session_mocker): # Directly u
temp_session.close() # Close the temporary session used for loading defaults
# Clear caches and patch
- print("DEBUG: Clearing db_utils.get_db_session cache.")
db_utils_module.get_db_session.cache_clear()
- print("DEBUG: Clearing db_utils.get_settings_manager cache.")
db_utils_module.get_settings_manager.cache_clear()
- print("DEBUG: Patching src.local_deep_research.utilities.db_utils.get_db_session.")
mock_get_db_session = session_mocker.patch("src.local_deep_research.utilities.db_utils.get_db_session")
mock_get_db_session.side_effect = SessionLocal
- print(f"DEBUG: get_db_session patched to use SessionLocal: {SessionLocal}")
- print("DEBUG: Patching src.local_deep_research.utilities.db_utils.get_settings_manager.")
mock_get_settings_manager = session_mocker.patch("src.local_deep_research.utilities.db_utils.get_settings_manager")
mock_get_settings_manager.side_effect = lambda: SettingsManager(db_session=mock_get_db_session())
- print("DEBUG: get_settings_manager patched to return SettingsManager with mock_get_db_session.")
- print("DEBUG: Yielding SessionLocal from setup_database_for_all_tests fixture.")
yield SessionLocal # Yield the SessionLocal class for individual tests to create sessions
- print("DEBUG: Teardown: Disposing SQLAlchemy engine.")
if engine:
engine.dispose() # Dispose the engine to close all connections
- print("DEBUG: SQLAlchemy engine disposed.")
- else:
- print("DEBUG: Engine was not initialized, no dispose needed.")
# tmp_path_factory handles deleting the temporary directory and its contents
- print("DEBUG: Exiting setup_database_for_all_tests fixture.")
@pytest.fixture
def mock_db_session(mocker):
- print("DEBUG: Providing mock_db_session fixture.")
return mocker.MagicMock()
@pytest.fixture
def mock_logger(mocker):
- print("DEBUG: Providing mock_logger fixture.")
return mocker.patch("src.local_deep_research.web.services.settings_manager.logger")
\ No newline at end of file