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.

fix(test): restore parent-package security attribute when snapshot is empty (#5037)

LearningCircuit80abafed18b4
diff --git a/tests/security/test_security_import_fallbacks_coverage.py b/tests/security/test_security_import_fallbacks_coverage.py
index e0a4098820..319716ea38 100644
--- a/tests/security/test_security_import_fallbacks_coverage.py
+++ b/tests/security/test_security_import_fallbacks_coverage.py
@@ -37,12 +37,21 @@ def _restore_security_module():
egress classification's Sensitivity), breaking identity checks in any
test that runs later in the same process against modules that imported
them earlier.
+
+ The `security` attribute on the parent package is restored to its exact
+ pre-test state as well (including absent): otherwise, when security was
+ never imported before this test, the crippled blocked module would stay
+ reachable via `from local_deep_research import security`, silently
+ presenting PathValidator/FileUploadValidator as None to later tests.
"""
saved = {
k: v
for k, v in sys.modules.items()
if "local_deep_research.security" in k
}
+ missing = object()
+ pkg = sys.modules.get("local_deep_research")
+ saved_boundary = getattr(pkg, "security", missing) if pkg else missing
yield
for k in [
k for k in list(sys.modules) if "local_deep_research.security" in k
@@ -58,6 +67,19 @@ def _restore_security_module():
parent = sys.modules.get(parent_name)
if parent is not None and child:
setattr(parent, child, module)
+ # The blocked reload also rebinds `security` on the already-imported
+ # parent package, and eviction from sys.modules does not undo that. If
+ # security had never been imported before this test (empty snapshot),
+ # the loop above cannot heal it and `from local_deep_research import
+ # security` would keep resolving to the crippled blocked module through
+ # the leftover attribute — restore its exact pre-test state instead.
+ pkg = sys.modules.get("local_deep_research")
+ if pkg is not None:
+ if saved_boundary is missing:
+ if hasattr(pkg, "security"):
+ delattr(pkg, "security")
+ else:
+ pkg.security = saved_boundary
class TestPathValidatorImportFallback: