~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
fix(ci): resolve 31 pytest + 10 Playwright failures blocking Create Release #1116 (#2396)
LearningCircuit75d754fff0ea
diff --git a/tests/auth_tests/test_encrypted_db.py b/tests/auth_tests/test_encrypted_db.pyindex a1112c46da..d0d5d783b0 100644--- a/tests/auth_tests/test_encrypted_db.py+++ b/tests/auth_tests/test_encrypted_db.py@@ -278,7 +278,7 @@ class TestConnectionVerification:conn = sqlcipher.connect(str(db_path))cursor = conn.cursor()# Existing database: key first, then cipher_* pragmas- set_sqlcipher_key(cursor, "testpassword123")+ set_sqlcipher_key(cursor, "testpassword123", db_path=db_path)apply_sqlcipher_pragmas(cursor, creation_mode=False)assert verify_sqlcipher_connection(cursor) is True@@ -304,7 +304,7 @@ class TestConnectionVerification:sqlcipher = get_sqlcipher_module()conn = sqlcipher.connect(str(db_path))cursor = conn.cursor()- set_sqlcipher_key(cursor, "wrongpassword")+ set_sqlcipher_key(cursor, "wrongpassword", db_path=db_path)apply_sqlcipher_pragmas(cursor, creation_mode=False)cursor.close()diff --git a/tests/conftest.py b/tests/conftest.pyindex ab95566866..6a247dabc4 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -117,6 +117,16 @@ def reset_all_singletons():except ImportError:pass+ # AdaptiveRateLimitTracker+ try:+ from local_deep_research.web_search_engines.rate_limiting import (+ tracker as rate_tracker_module,+ )++ rate_tracker_module._tracker_instance = None+ except ImportError:+ pass+_reset()yield_reset()diff --git a/tests/database/test_sqlcipher_integration.py b/tests/database/test_sqlcipher_integration.pyindex abcea59584..fd22517e85 100644--- a/tests/database/test_sqlcipher_integration.py+++ b/tests/database/test_sqlcipher_integration.py@@ -4341,7 +4341,7 @@ class TestSQLCipherIntegration:# After keying successfully, status should be 1# (or non-zero indicating ready state)status_value = after_key_status[0]- assert status_value in (1, "ok", True), (+ assert status_value in (1, "1", "ok", True), (f"Expected keyed status, got: {status_value}")except Exception as e:diff --git a/tests/ui_tests/playwright/tests/auth-pages-mobile.spec.js b/tests/ui_tests/playwright/tests/auth-pages-mobile.spec.jsindex 3bc940e26a..f1ee09bb7b 100644--- a/tests/ui_tests/playwright/tests/auth-pages-mobile.spec.js+++ b/tests/ui_tests/playwright/tests/auth-pages-mobile.spec.js@@ -287,9 +287,10 @@ test.describe('Auth Pages Mobile', () => {const registerLink = page.locator('a[href*="register"]');if (await registerLink.count() > 0) {- await registerLink.click();- await page.waitForLoadState('domcontentloaded');- await page.waitForURL('**/auth/register', { timeout: 5000 });+ await Promise.all([+ page.waitForURL('**/auth/register', { timeout: 15000 }),+ registerLink.click(),+ ]);expect(page.url()).toContain('/auth/register');}@@ -301,9 +302,10 @@ test.describe('Auth Pages Mobile', () => {const loginLink = page.locator('a[href*="login"]');await expect(loginLink).toBeVisible();- await loginLink.click();- await page.waitForLoadState('domcontentloaded');- await page.waitForURL('**/auth/login', { timeout: 5000 });+ await Promise.all([+ page.waitForURL('**/auth/login', { timeout: 15000 }),+ loginLink.click(),+ ]);expect(page.url()).toContain('/auth/login');});diff --git a/tests/ui_tests/playwright/tests/interactive-states.spec.js b/tests/ui_tests/playwright/tests/interactive-states.spec.jsindex 837f0f9e26..2bacc8f1ae 100644--- a/tests/ui_tests/playwright/tests/interactive-states.spec.js+++ b/tests/ui_tests/playwright/tests/interactive-states.spec.js@@ -152,6 +152,7 @@ test.describe('Settings - Search Filtering', () => {if (await searchInput.count() > 0 && await searchInput.isVisible()) {await searchInput.fill('zzz_nonexistent_setting_xyz');+ await page.waitForLoadState('domcontentloaded');await page.waitForFunction(() => {const items = document.querySelectorAll('.ldr-settings-group, .ldr-setting-item, [class*="setting"]');let visibleCount = 0;@@ -162,7 +163,7 @@ test.describe('Settings - Search Filtering', () => {}});return visibleCount < 5;- }, { timeout: 5000 }).catch(() => {});+ }, { timeout: 10000 });// Check that no settings are visible or an empty state is shownconst visibleSettings = await page.evaluate(() => {@@ -213,12 +214,12 @@ test.describe('Mobile More Menu - Navigation', () => {if (await moreBtn.count() > 0) {await moreBtn.click();- // Look for Metrics link in the opened menu/sheet- const metricsLink = page.locator('a:has-text("Metrics"), [href*="metrics"]');- await metricsLink.first().waitFor({ state: 'visible' });+ // Look for Metrics item in the opened sheet menu (rendered as button, not <a>)+ const metricsItem = page.locator('.ldr-mobile-sheet-item:has-text("Metrics"), button[data-item-id="metrics"], a:has-text("Metrics"), [href*="metrics"]');+ await metricsItem.first().waitFor({ state: 'visible' });- if (await metricsLink.count() > 0 && await metricsLink.first().isVisible()) {- await metricsLink.first().click();+ if (await metricsItem.count() > 0 && await metricsItem.first().isVisible()) {+ await metricsItem.first().click();await page.waitForLoadState('domcontentloaded');// Should now be on the metrics page@@ -227,7 +228,7 @@ test.describe('Mobile More Menu - Navigation', () => {}});- test('navigate to Library via More menu', async ({ page, isMobile }, testInfo) => {+ test('navigate to Library via bottom nav', async ({ page, isMobile }, testInfo) => {if (!isMobile) {test.skip();return;@@ -242,20 +243,14 @@ test.describe('Mobile More Menu - Navigation', () => {await page.goto('/');await waitForPageLoad(page, { path: '/' });- const moreBtn = page.locator('.ldr-mobile-bottom-nav button:has-text("More"), .ldr-mobile-bottom-nav [aria-label="More"]');-- if (await moreBtn.count() > 0) {- await moreBtn.click();+ // Library is a bottom nav tab, not in the "More" sheet menu+ const libraryTab = page.locator('.ldr-mobile-nav-tab[data-tab-id="library"], .ldr-mobile-bottom-nav a:has-text("Library"), .ldr-mobile-bottom-nav [href*="library"]');- const libraryLink = page.locator('a:has-text("Library"), [href*="library"]');- await libraryLink.first().waitFor({ state: 'visible' });+ if (await libraryTab.count() > 0) {+ await libraryTab.first().click();+ await page.waitForLoadState('domcontentloaded');- if (await libraryLink.count() > 0 && await libraryLink.first().isVisible()) {- await libraryLink.first().click();- await page.waitForLoadState('domcontentloaded');-- expect(page.url()).toContain('/library');- }+ expect(page.url()).toContain('/library');}});diff --git a/tests/web/routes/test_open_folder_subprocess.py b/tests/web/routes/test_open_folder_subprocess.pydeleted file mode 100644index ed8a60a26e..0000000000--- a/tests/web/routes/test_open_folder_subprocess.py+++ /dev/null@@ -1,276 +0,0 @@-"""-Tests for subprocess.run usage in open folder functions.--These tests verify that subprocess.run is used with start_new_session=True-on Linux and macOS to prevent zombie processes and file descriptor leaks.--The tests use source code inspection to verify the implementation details,-which is more reliable than integration tests for verifying specific-subprocess parameters.-"""--import inspect-import re---class TestSubprocessRunNotPopen:- """Tests to verify Popen is NOT used (would cause zombie processes)."""-- def test_settings_routes_open_file_location_uses_subprocess_run_not_popen(- self,- ):- """Verify settings_routes.open_file_location uses subprocess.run, not Popen."""- from local_deep_research.web.routes import settings_routes-- func_source = inspect.getsource(settings_routes.open_file_location)-- # subprocess.run should be used- assert "subprocess.run" in func_source, (- "open_file_location should use subprocess.run"- )-- # Popen should NOT be called in this function- # Note: "Popen" may appear in comments explaining why we don't use it,- # so we check for actual Popen calls (Popen( or subprocess.Popen)- assert (- "Popen(" not in func_source- and "subprocess.Popen" not in func_source- ), "open_file_location should NOT call Popen (causes zombie processes)"-- def test_research_routes_open_file_location_uses_subprocess_run_not_popen(- self,- ):- """Verify research_routes.open_file_location uses subprocess.run, not Popen."""- from local_deep_research.web.routes import research_routes-- func_source = inspect.getsource(research_routes.open_file_location)-- # subprocess.run should be used- assert "subprocess.run" in func_source, (- "open_file_location should use subprocess.run"- )-- # Popen should NOT be used in this function- assert "Popen" not in func_source, (- "open_file_location should NOT use Popen (causes zombie processes)"- )---class TestStartNewSessionOnUnix:- """Tests to verify start_new_session=True is used on Unix systems."""-- def test_settings_routes_uses_start_new_session_for_xdg_open(self):- """Verify settings_routes uses start_new_session=True with xdg-open (Linux)."""- from local_deep_research.web.routes import settings_routes-- func_source = inspect.getsource(settings_routes.open_file_location)-- # Check for xdg-open usage- assert "xdg-open" in func_source, (- "open_file_location should use xdg-open on Linux"- )-- # Check for start_new_session parameter- assert "start_new_session=True" in func_source, (- "open_file_location should use start_new_session=True"- )-- # Verify the subprocess.run call with xdg-open has start_new_session- # Look for the pattern: subprocess.run(["xdg-open", ...], start_new_session=True- linux_block_match = re.search(- r'else:.*?#.*?Linux.*?subprocess\.run\(\s*\["xdg-open".*?start_new_session\s*=\s*True',- func_source,- re.DOTALL,- )- assert linux_block_match is not None, (- "Linux xdg-open call should include start_new_session=True"- )-- def test_settings_routes_uses_start_new_session_for_macos_open(self):- """Verify settings_routes uses start_new_session=True with open (macOS)."""- from local_deep_research.web.routes import settings_routes-- func_source = inspect.getsource(settings_routes.open_file_location)-- # Check for Darwin/macOS handling- assert "Darwin" in func_source, (- "open_file_location should handle Darwin/macOS"- )-- # Check that macOS uses the 'open' command with start_new_session- macos_block_match = re.search(- r'Darwin.*?subprocess\.run\(\s*\["open".*?start_new_session\s*=\s*True',- func_source,- re.DOTALL,- )- assert macos_block_match is not None, (- "macOS open call should include start_new_session=True"- )-- def test_research_routes_uses_start_new_session_for_xdg_open(self):- """Verify research_routes uses start_new_session=True with xdg-open (Linux)."""- from local_deep_research.web.routes import research_routes-- func_source = inspect.getsource(research_routes.open_file_location)-- # Check for xdg-open usage- assert "xdg-open" in func_source, (- "open_file_location should use xdg-open on Linux"- )-- # Check for start_new_session parameter- assert "start_new_session=True" in func_source, (- "open_file_location should use start_new_session=True"- )-- # Verify the subprocess.run call with xdg-open has start_new_session- linux_block_match = re.search(- r'else:.*?#.*?Linux.*?subprocess\.run\(\s*\["xdg-open".*?start_new_session\s*=\s*True',- func_source,- re.DOTALL,- )- assert linux_block_match is not None, (- "Linux xdg-open call should include start_new_session=True"- )-- def test_research_routes_uses_start_new_session_for_macos_open(self):- """Verify research_routes uses start_new_session=True with open (macOS)."""- from local_deep_research.web.routes import research_routes-- func_source = inspect.getsource(research_routes.open_file_location)-- # Check for Darwin/macOS handling- assert "Darwin" in func_source, (- "open_file_location should handle Darwin/macOS"- )-- # Check that macOS uses the 'open' command with start_new_session- macos_block_match = re.search(- r'Darwin.*?subprocess\.run\(\s*\["open".*?start_new_session\s*=\s*True',- func_source,- re.DOTALL,- )- assert macos_block_match is not None, (- "macOS open call should include start_new_session=True"- )---class TestWindowsDoesNotUseStartNewSession:- """Tests to verify Windows does not need start_new_session (uses explorer)."""-- def test_settings_routes_windows_uses_explorer(self):- """Verify settings_routes uses explorer on Windows (no start_new_session needed)."""- from local_deep_research.web.routes import settings_routes-- func_source = inspect.getsource(settings_routes.open_file_location)-- # Windows should use explorer- assert '"Windows"' in func_source or "'Windows'" in func_source, (- "open_file_location should check for Windows platform"- )-- # Windows block should use explorer- windows_match = re.search(- r'Windows.*?subprocess\.run\(\s*\["explorer"',- func_source,- re.DOTALL,- )- assert windows_match is not None, "Windows should use explorer command"-- def test_research_routes_windows_uses_explorer(self):- """Verify research_routes uses explorer on Windows."""- from local_deep_research.web.routes import research_routes-- func_source = inspect.getsource(research_routes.open_file_location)-- # Windows should use explorer- assert '"Windows"' in func_source or "'Windows'" in func_source, (- "open_file_location should check for Windows platform"- )-- # Windows block should use explorer- windows_match = re.search(- r'Windows.*?subprocess\.run\(\s*\["explorer"',- func_source,- re.DOTALL,- )- assert windows_match is not None, "Windows should use explorer command"---class TestSubprocessCommentDocumentation:- """Tests to verify the code has proper comments about zombie process prevention."""-- def test_settings_routes_has_zombie_prevention_comment(self):- """Verify settings_routes documents why start_new_session is used."""- from local_deep_research.web.routes import settings_routes-- func_source = inspect.getsource(settings_routes.open_file_location)-- # Should have comment explaining the fix- assert "start_new_session" in func_source and (- "zombie" in func_source.lower()- or "detach" in func_source.lower()- or "file descriptor" in func_source.lower()- ), "Code should document why start_new_session is used"-- def test_research_routes_has_detach_comment(self):- """Verify research_routes documents subprocess detachment."""- from local_deep_research.web.routes import research_routes-- func_source = inspect.getsource(research_routes.open_file_location)-- # Should have comment explaining the fix- assert "start_new_session" in func_source and (- "detach" in func_source.lower()- or "fully detach" in func_source.lower()- ), (- "Code should document why start_new_session is used (detach subprocess)"- )---class TestPlatformHandling:- """Tests for proper platform detection and handling."""-- def test_settings_routes_handles_all_platforms(self):- """Verify settings_routes handles Windows, macOS, and Linux."""- from local_deep_research.web.routes import settings_routes-- func_source = inspect.getsource(settings_routes.open_file_location)-- # Should handle all three platforms- assert "Windows" in func_source, "Should handle Windows"- assert "Darwin" in func_source, "Should handle macOS (Darwin)"- # Linux is the else case, verified by xdg-open- assert "xdg-open" in func_source, "Should handle Linux with xdg-open"-- def test_research_routes_handles_all_platforms(self):- """Verify research_routes handles Windows, macOS, and Linux."""- from local_deep_research.web.routes import research_routes-- func_source = inspect.getsource(research_routes.open_file_location)-- # Should handle all three platforms- assert "Windows" in func_source, "Should handle Windows"- assert "Darwin" in func_source, "Should handle macOS (Darwin)"- # Linux is the else case, verified by xdg-open- assert "xdg-open" in func_source, "Should handle Linux with xdg-open"-- def test_settings_routes_uses_platform_system(self):- """Verify settings_routes uses platform.system() for OS detection."""- from local_deep_research.web.routes import settings_routes-- func_source = inspect.getsource(settings_routes.open_file_location)-- assert "platform.system()" in func_source, (- "Should use platform.system() for OS detection"- )-- def test_research_routes_uses_platform_system(self):- """Verify research_routes uses platform.system() for OS detection."""- from local_deep_research.web.routes import research_routes-- func_source = inspect.getsource(research_routes.open_file_location)-- assert "platform.system()" in func_source, (- "Should use platform.system() for OS detection"- )diff --git a/tests/web_search_engines/__init__.py b/tests/web_search_engines/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/tests/web_search_engines/engines/conftest.py b/tests/web_search_engines/engines/conftest.pynew file mode 100644index 0000000000..adcaeb56f9--- /dev/null+++ b/tests/web_search_engines/engines/conftest.py@@ -0,0 +1,18 @@+from unittest.mock import Mock, patch++import pytest++[email protected](autouse=True)+def mock_rate_tracker():+ """Mock rate tracker for all engine unit tests."""+ mock_tracker = Mock()+ mock_tracker.enabled = False+ mock_tracker.apply_rate_limit.return_value = 0.0+ mock_tracker.get_wait_time.return_value = 0.0+ mock_tracker.record_outcome.return_value = None+ with patch(+ "local_deep_research.web_search_engines.search_engine_base.get_tracker",+ return_value=mock_tracker,+ ):+ yield mock_tracker