~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
bunch of debug garbage
ScottVRc7ea823a761d
diff --git a/tests/conftest.py b/tests/conftest.pyindex 864e8f8f70..0f10f4a0d1 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -1,4 +1,4 @@-from typing import Any+import os # Import os for additional path debuggingimport pytestfrom sqlalchemy import create_engine@@ -21,36 +21,36 @@ def setup_database_for_all_tests(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."""-- # 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:- if hasattr(db_utils_module.get_db_session, "cache_clear"):- db_utils_module.get_db_session.cache_clear()- if hasattr(db_utils_module.get_settings_manager, "cache_clear"):- db_utils_module.get_settings_manager.cache_clear()- 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-- except Exception as e:- print(f"ERROR: Failed to clear db_utils caches aggressively: {e}")- # This shouldn't prevent test run, but indicates a problem with cache_clear+ print("\nDEBUG: Entering setup_database_for_all_tests fixture.")# Debug tmp_path_factory behaviortemp_dir = tmp_path_factory.mktemp("db_test_data")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 = Nonetry:+ 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}")raisetry:+ 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@@ -59,64 +59,54 @@ def setup_database_for_all_tests(raiseSessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)- temp_session = SessionLocal()- temp_settings_manager = SettingsManager(db_session=temp_session)-- try:- temp_settings_manager.load_from_defaults_file(commit=True)- except Exception as e:- print(f"ERROR: Failed to load default settings: {e}")- temp_session.rollback() # Rollback if default loading fails- raise # Re-raise to fail the test if default loading is critical- finally:- temp_session.close() # Close the temporary session used for loading defaults+ print("DEBUG: SessionLocal sessionmaker created.")# 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- # tmp_path_factory handles deleting the temporary directory and its+ 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): # This will still use the default function-scoped mocker+def mock_db_session(mocker):+ print("DEBUG: Providing mock_db_session fixture.")return mocker.MagicMock()@pytest.fixturedef mock_logger(mocker):- mocked_logger = mocker.patch(- "src.local_deep_research.web.services.settings_manager.logger"- )-- def _print_to_console(message: str, *args: Any) -> None:- # Handle loguru formatting.- message = message.format(*args)- print(f"LOG: {message}")- return mocker.DEFAULT-- # Pass through logged messages to the console.- mocked_logger.debug = mocker.MagicMock(side_effect=_print_to_console)- mocked_logger.info = mocker.MagicMock(side_effect=_print_to_console)- mocked_logger.warning = mocker.MagicMock(side_effect=_print_to_console)- mocked_logger.error = mocker.MagicMock(side_effect=_print_to_console)- mocked_logger.critical = mocker.MagicMock(side_effect=_print_to_console)- mocked_logger.exception = mocker.MagicMock(side_effect=_print_to_console)-- return mocked_logger+ print("DEBUG: Providing mock_logger fixture.")+ return mocker.patch("src.local_deep_research.web.services.settings_manager.logger")