From efaa87aba2ee1df6a54424da6839e1eeecf91753 Mon Sep 17 00:00:00 2001 From: chaog992 <338238273+chaog992@users.noreply.github.com> Date: Fri, 9 Oct 2026 11:17:14 +0800 Subject: [PATCH] tools tests: align test_setup_risk's WSL mock with install() (the KV-streaming rule test failed inside WSL) RulesAgreeWithTheWrittenConfig.test_the_streaming_rule_is_the_flag_setup_writes runs setup.main() through test_setup_golden's install(), which mocks is_wsl() to False, and then asked setup.kv_streaming_wanted() outside that mock. Inside WSL the real is_wsl() is True, so the rule answered "no streaming" while the config setup wrote for the mocked PC has --kv-resident, and the test failed at its first 131072 case (Q2_0, int8, auto). With is_wsl() the same on both sides, setup and the rule agree in all 54 cases, inside WSL and out. The test method now runs under the same is_wsl mock as install(), the test-only fix the unsloth tests got for #974 (d1ec32b). setup.py is unchanged; where is_wsl() is already False (Windows, native Linux) the test runs as before. Tests: python3 tools/test_setup_risk.py (WSL2, Python 3.12.3: was FAILED (failures=1), now 40 tests OK); the other 27 tools/test_setup_*.py files give the same results as before. --- tools/test_setup_risk.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/test_setup_risk.py b/tools/test_setup_risk.py index a76f77a8..f6689c49 100644 --- a/tools/test_setup_risk.py +++ b/tools/test_setup_risk.py @@ -488,6 +488,7 @@ class RulesAgreeWithTheWrittenConfig(unittest.TestCase): def go(self, ram, cards, model, *flags): return install(ram, cards, ["--family", "qwen", "--model", model, "--no-start", *flags]) + @mock.patch.object(setup, "is_wsl", lambda: False) # #974: not WSL, as in install() def test_the_streaming_rule_is_the_flag_setup_writes(self): for model, ctx, kv, choice in itertools.product(("Q2_0", "IQ3_XXS", "IQ3_S"), ("32768", "131072"), ("int8", "q4_0", "k8v4"), ("auto", "on", "off")):