From 4b4201cfbc50f904fcdea84b9b7ac751273a26aa Mon Sep 17 00:00:00 2001 From: EMRG Evolution Date: Thu, 20 Aug 2026 16:42:36 +0800 Subject: [PATCH] =?UTF-8?q?emrg:=20isolate=20stop=5Fdaemon=20in=20test=5Fs?= =?UTF-8?q?top=5Fall=5Fprocess=5Fresidual=5Fstill=5Faborts=20(=E2=9B=94=20?= =?UTF-8?q?host=20red=20line)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test called _stop_all.stop_all() without monkeypatching stop_daemon, which REALLY connects to ws://127.0.0.1:56031 and shuts down the running emrgd — observed twice on 2026-08-20 16:18/16:25 (emrgd.log 'shutdown requested by client (source=stop_all)') while running the full pytest suite. The other two stop_all() tests in the file already isolate stop_daemon; this one was the missed spot. Fix: add monkeypatch.setattr(_stop_all, 'stop_daemon', lambda: None) with a ⛔ red-line comment, matching the file's convention. Full-suite audit confirms no other un-isolated stop_all()/stop_daemon() real-execution tests remain (test_installer_stop.py is static source analysis; scheduler stop_all() stops handler coroutines, not the daemon). --- tests/test_stop_all.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_stop_all.py b/tests/test_stop_all.py index b78cab17..065842b0 100644 --- a/tests/test_stop_all.py +++ b/tests/test_stop_all.py @@ -669,6 +669,10 @@ def test_stop_all_process_residual_still_aborts(self, monkeypatch, capsys): residuals do not (rant 2026-08-18T21:24:48 #2c/#5).""" monkeypatch.setattr(_stop_all, "is_win", lambda: True) monkeypatch.setattr(_stop_all.time, "sleep", lambda *a, **k: None) + # ⛔ 最高原则(宿主 2026-08-18T22:58):必须隔离 stop_daemon——本机运行 + # pytest 时真实 stop_all() 会连 ws 发 shutdown 杀死正在运行的 emrgd + # (2026-08-20 16:18/16:25 两次实证)。同文件其它 stop_all() 测试均有此隔离。 + monkeypatch.setattr(_stop_all, "stop_daemon", lambda: None) monkeypatch.setattr(_stop_all, "check_install_writable", lambda: []) monkeypatch.setattr( _stop_all, "verify",