~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
test(downloaders): fix GC-timing flake in context-manager close test (#4444)
LearningCircuitf3ffed02814e
diff --git a/changelog.d/+base-downloader-close-test-instance-patch.misc.md b/changelog.d/+base-downloader-close-test-instance-patch.misc.mdnew file mode 100644index 0000000000..171c7c83d6--- /dev/null+++ b/changelog.d/+base-downloader-close-test-instance-patch.misc.md@@ -0,0 +1 @@+Tests: fix a GC-timing flake in ``test_base_downloader.py::test_context_manager_calls_close``. The test patched ``close`` on the ``BaseDownloader`` *class*, but ``BaseDownloader.__del__`` also calls ``self.close()`` — so whenever the garbage collector happened to finalize a downloader left over from an earlier test while the patch was live, the shared class-level mock counted an extra call and the assertion failed with "Expected 'close' to have been called once. Called 2 times." (seen failing an unrelated PR's CI, #4415). Patch on the instance instead — the same pattern the neighbouring ``__del__`` test already uses — which is immune to other instances' finalizers (mechanism reproduced deterministically both ways).diff --git a/tests/research_library/downloaders/test_base_downloader.py b/tests/research_library/downloaders/test_base_downloader.pyindex aa6775f872..a08f860c05 100644--- a/tests/research_library/downloaders/test_base_downloader.py+++ b/tests/research_library/downloaders/test_base_downloader.py@@ -448,14 +448,18 @@ class TestBaseDownloaderResourceCleanup:def test_context_manager_calls_close(self, mocker):"""Test that exiting context manager calls close()."""- from local_deep_research.research_library.downloaders.base import (- BaseDownloader,- )-- mock_close = mocker.patch.object(BaseDownloader, "close")+ downloader = ConcreteDownloader()+ # Patch on the INSTANCE (same pattern as the __del__ test above),+ # not on BaseDownloader: __del__ also calls self.close(), so a+ # class-level mock is shared by every downloader instance alive in+ # the process — whenever the GC happens to finalize one left over+ # from an earlier test while this test runs, the count flakes+ # ("Expected 'close' to have been called once. Called 2 times.").+ # An instance-level patch only sees calls from THIS downloader.+ mock_close = mocker.patch.object(downloader, "close")- with ConcreteDownloader() as downloader:- assert downloader is not None+ with downloader as ctx:+ assert ctx is downloadermock_close.assert_called_once()