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.

test: reverse-order patch teardown in remaining _auth_client helpers (leak sweep) (#4866)

LearningCircuit40228a2d32f8
diff --git a/tests/research_library/deletion/routes/test_delete_routes_coverage.py b/tests/research_library/deletion/routes/test_delete_routes_coverage.py
index d6b7427668..229aebcd4b 100644
--- a/tests/research_library/deletion/routes/test_delete_routes_coverage.py
+++ b/tests/research_library/deletion/routes/test_delete_routes_coverage.py
@@ -73,7 +73,7 @@ def _auth_client(app, doc_svc=None, coll_svc=None, bulk_svc=None):
sess["session_id"] = "test-session-id"
yield client
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/research_library/deletion/routes/test_delete_routes_http.py b/tests/research_library/deletion/routes/test_delete_routes_http.py
index aa72681817..1a8a0c651d 100644
--- a/tests/research_library/deletion/routes/test_delete_routes_http.py
+++ b/tests/research_library/deletion/routes/test_delete_routes_http.py
@@ -71,7 +71,7 @@ def _authenticated_client(
sess["session_id"] = "test-session-id"
yield client
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/research_library/routes/test_library_routes.py b/tests/research_library/routes/test_library_routes.py
index 226b5807f0..39e229532a 100644
--- a/tests/research_library/routes/test_library_routes.py
+++ b/tests/research_library/routes/test_library_routes.py
@@ -169,7 +169,7 @@ def _authenticated_client(app):
sess["session_id"] = "test-session-id"
yield client
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/research_library/routes/test_library_routes_coverage.py b/tests/research_library/routes/test_library_routes_coverage.py
index 28b0e65e17..603b86f121 100644
--- a/tests/research_library/routes/test_library_routes_coverage.py
+++ b/tests/research_library/routes/test_library_routes_coverage.py
@@ -177,7 +177,7 @@ def _auth_client(
},
)
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/research_library/routes/test_library_routes_deep_coverage.py b/tests/research_library/routes/test_library_routes_deep_coverage.py
index 0ab8753ff4..8c04a429be 100644
--- a/tests/research_library/routes/test_library_routes_deep_coverage.py
+++ b/tests/research_library/routes/test_library_routes_deep_coverage.py
@@ -147,7 +147,7 @@ def _auth_client(
},
)
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/research_library/routes/test_library_routes_extra_coverage.py b/tests/research_library/routes/test_library_routes_extra_coverage.py
index 4f6bc88fa2..9d089efbbe 100644
--- a/tests/research_library/routes/test_library_routes_extra_coverage.py
+++ b/tests/research_library/routes/test_library_routes_extra_coverage.py
@@ -166,7 +166,7 @@ def _auth_client(
},
)
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/research_library/routes/test_library_routes_view_coverage.py b/tests/research_library/routes/test_library_routes_view_coverage.py
index cfc41eb836..38018a99d2 100644
--- a/tests/research_library/routes/test_library_routes_view_coverage.py
+++ b/tests/research_library/routes/test_library_routes_view_coverage.py
@@ -158,7 +158,7 @@ def _auth_client(
},
)
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/security/test_egress_settings_save_validators.py b/tests/security/test_egress_settings_save_validators.py
index 459cd0d0ce..a39810100a 100644
--- a/tests/security/test_egress_settings_save_validators.py
+++ b/tests/security/test_egress_settings_save_validators.py
@@ -234,7 +234,7 @@ def _routed_client(existing_settings):
sess["session_id"] = "sid"
yield client
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/web/routes/test_context_overflow_api_http.py b/tests/web/routes/test_context_overflow_api_http.py
index ac6fb536e3..f2efd507ed 100644
--- a/tests/web/routes/test_context_overflow_api_http.py
+++ b/tests/web/routes/test_context_overflow_api_http.py
@@ -99,7 +99,7 @@ def _authenticated_client(app):
sess["session_id"] = "test-session-id"
yield client, _mock_db_session, _mock_query
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/web/routes/test_context_overflow_logic.py b/tests/web/routes/test_context_overflow_logic.py
index ae43f66ec0..0e7fa18cbc 100644
--- a/tests/web/routes/test_context_overflow_logic.py
+++ b/tests/web/routes/test_context_overflow_logic.py
@@ -85,7 +85,7 @@ def _authenticated_client(app):
sess["session_id"] = "test-session-id"
yield client, _mock_db_session, _mock_query
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/web/routes/test_encrypted_db_password_check.py b/tests/web/routes/test_encrypted_db_password_check.py
index 2e98382615..a747aafc1c 100644
--- a/tests/web/routes/test_encrypted_db_password_check.py
+++ b/tests/web/routes/test_encrypted_db_password_check.py
@@ -129,7 +129,7 @@ def _authenticated_client(app, has_encryption=False, password_available=True):
sess["session_id"] = "test-session-id"
yield client, mock_start, _mock_db_session
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
@@ -267,7 +267,7 @@ def _authenticated_followup_client(
sess["session_id"] = "test-session-id"
yield client, _mock_db_session
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/web/routes/test_settings_routes_corrupted_coverage.py b/tests/web/routes/test_settings_routes_corrupted_coverage.py
index fb5f9e493d..ce087ba10d 100644
--- a/tests/web/routes/test_settings_routes_corrupted_coverage.py
+++ b/tests/web/routes/test_settings_routes_corrupted_coverage.py
@@ -110,7 +110,7 @@ def _authenticated_client(app):
sess["session_id"] = "test-session-id"
yield client
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/web/routes/test_settings_routes_deep_coverage.py b/tests/web/routes/test_settings_routes_deep_coverage.py
index a5002498df..45f6026ff2 100644
--- a/tests/web/routes/test_settings_routes_deep_coverage.py
+++ b/tests/web/routes/test_settings_routes_deep_coverage.py
@@ -125,7 +125,7 @@ def _authenticated_client(app):
sess["session_id"] = "test-session-id"
yield client
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/web/routes/test_settings_routes_deep_coverage2.py b/tests/web/routes/test_settings_routes_deep_coverage2.py
index abd621417b..a53926900d 100644
--- a/tests/web/routes/test_settings_routes_deep_coverage2.py
+++ b/tests/web/routes/test_settings_routes_deep_coverage2.py
@@ -150,7 +150,7 @@ def _authenticated_client(app, mock_settings=None):
sess["session_id"] = "test-session-id"
yield client, _mock_db_session
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/web/routes/test_settings_routes_gaps_coverage.py b/tests/web/routes/test_settings_routes_gaps_coverage.py
index 7db15f4268..69abe14d43 100644
--- a/tests/web/routes/test_settings_routes_gaps_coverage.py
+++ b/tests/web/routes/test_settings_routes_gaps_coverage.py
@@ -63,7 +63,7 @@ def _authenticated_client(app):
sess["session_id"] = "test-session-id"
yield client
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
@@ -231,7 +231,7 @@ def _client_with_db(app, db_setting):
sess["session_id"] = "test-session-id"
yield client, db
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/web/routes/test_settings_routes_save_validation_coverage.py b/tests/web/routes/test_settings_routes_save_validation_coverage.py
index 1f037f3153..b6186a021c 100644
--- a/tests/web/routes/test_settings_routes_save_validation_coverage.py
+++ b/tests/web/routes/test_settings_routes_save_validation_coverage.py
@@ -112,7 +112,7 @@ def _authenticated_client(app):
sess["session_id"] = "test-session-id"
yield client
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/web/routes/test_settings_routes_security.py b/tests/web/routes/test_settings_routes_security.py
index 5df2cb9876..30b0127a07 100644
--- a/tests/web/routes/test_settings_routes_security.py
+++ b/tests/web/routes/test_settings_routes_security.py
@@ -86,7 +86,7 @@ def _authenticated_client(app, mock_settings=None):
sess["session_id"] = "test-session-id"
yield client, _mock_db_session
finally:
- for p in patches:
+ for p in reversed(patches):
p.stop()
diff --git a/tests/web/services/test_research_service_coverage_gaps.py b/tests/web/services/test_research_service_coverage_gaps.py
index 1bf1fe51ce..154102b87e 100644
--- a/tests/web/services/test_research_service_coverage_gaps.py
+++ b/tests/web/services/test_research_service_coverage_gaps.py
@@ -135,7 +135,7 @@ class TestRunResearchEarlyTermination:
try:
func(1, "test query", "quick", username="testuser")
finally:
- for p in stack:
+ for p in reversed(stack):
p.stop()
# cleanup_research_resources must have been called. Terminated
@@ -202,7 +202,7 @@ class TestSettingsContextInnerClass:
settings_snapshot=snapshot,
)
finally:
- for p in stack:
+ for p in reversed(stack):
p.stop()
assert len(captured_contexts) == 1
@@ -248,7 +248,7 @@ class TestSettingsContextInnerClass:
settings_snapshot={"search.tool": "searxng"},
)
finally:
- for p in stack:
+ for p in reversed(stack):
p.stop()
ctx = captured_contexts[0]
@@ -292,7 +292,7 @@ class TestWorkerFailsClosedOnMissingPrimary:
# run_research_process handles it as a failed run internally.
func(1, "test", "quick", username="user1", settings_snapshot={})
finally:
- for p in stack:
+ for p in reversed(stack):
p.stop()
# Fail closed: the run aborted before the search system ran. (A
@@ -356,7 +356,7 @@ class TestProgressCallbackTerminationCheck:
settings_snapshot={"search.tool": "searxng"},
)
finally:
- for p in stack:
+ for p in reversed(stack):
p.stop()
# The function should not propagate ResearchTerminatedException
@@ -399,7 +399,7 @@ class TestLLMConfigErrorRaisesValueError:
settings_snapshot={"search.tool": "searxng"},
)
finally:
- for p in stack:
+ for p in reversed(stack):
p.stop()
return mock_qp
@@ -481,7 +481,7 @@ class TestSearchEngineConfigError:
settings_snapshot={"search.tool": "searxng"},
)
finally:
- for p in stack:
+ for p in reversed(stack):
p.stop()
return mock_qp
@@ -572,7 +572,7 @@ class TestSearchErrorClassification:
settings_snapshot={"search.tool": "searxng"},
)
finally:
- for p in stack:
+ for p in reversed(stack):
p.stop()
return mock_qp
@@ -903,7 +903,7 @@ class TestUnexpectedFailureDoesNotLeakRawException:
settings_snapshot={"search.tool": "searxng"},
)
finally:
- for p in stack:
+ for p in reversed(stack):
p.stop()
assert "error_message" in captured, (