Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Tests: drop duplicate tests and fix three that checked nothing new (#13211)
Leo Borcherding06c33f153534
diff --git a/studio/backend/tests/test_combined_update.py b/studio/backend/tests/test_combined_update.pyindex 3aa88c61ba2..5b2303b94b4 100644--- a/studio/backend/tests/test_combined_update.py+++ b/studio/backend/tests/test_combined_update.py@@ -857,9 +857,10 @@ def _slim_phase(**over):def _llama_installed_as(monkeypatch, backend, asset, *, whisper_kind):monkeypatch.setattr(wupd, "_installed_llama_bundle", lambda: (backend, asset))monkeypatch.setattr(wupd, "_find_binary", lambda: "whisper-server")- monkeypatch.setattr(- wupd, "read_install_marker", lambda _b: {"install_kind": whisper_kind, "backend": "rocm"}- )+ marker = {"backend": "rocm"}+ if whisper_kind is not None:+ marker["install_kind"] = whisper_kind+ monkeypatch.setattr(wupd, "read_install_marker", lambda _b: dict(marker))def test_a_migrated_llama_re_pairs_the_chained_phase(monkeypatch):@@ -978,7 +979,8 @@ def test_a_legacy_fat_install_is_pre_flighted_too(monkeypatch):monkeypatch.setattr(wupd, "run_chained_phase", must_not_install)- # No install_kind at all: the legacy fat marker.+ # No install_kind at all: the legacy fat marker, read because llama moved backends.+ _llama_installed_as(monkeypatch, "vulkan", "vulkan.zip", whisper_kind = None)assert wupd.run_chained_phase_after_llama(_slim_phase(), lambda _f: None) == {"skipped": True,"skip_reason": "paired_llama_unavailable",diff --git a/studio/backend/tests/test_edit_file_tool.py b/studio/backend/tests/test_edit_file_tool.pyindex 488e84be1f2..7c43371781f 100644--- a/studio/backend/tests/test_edit_file_tool.py+++ b/studio/backend/tests/test_edit_file_tool.py@@ -253,8 +253,9 @@ class TestReviewFindings:assert not result.startswith("Error:")assert (workdir / "a.py").read_text() == "x = 2\n"- def test_a_habit_path_outside_the_workdir_still_remaps(self, workdir):+ def test_a_habit_path_outside_the_workdir_still_remaps(self, workdir, monkeypatch):# The fix above must not switch off the remap it narrows.+ monkeypatch.setattr(tools, "_MISSING_PATH_PREFIXES", (str(workdir.parent), "/mnt/data"))result = _edit(path = "/mnt/data/out.txt", old_string = "", new_string = "hi\n")assert not result.startswith("Error:")assert (workdir / "out.txt").read_text() == "hi\n"diff --git a/studio/backend/tests/test_gemini_provider.py b/studio/backend/tests/test_gemini_provider.pyindex 548c9c898ef..425d1366086 100644--- a/studio/backend/tests/test_gemini_provider.py+++ b/studio/backend/tests/test_gemini_provider.py@@ -867,15 +867,6 @@ def test_boolean_caching_does_not_set_cached_content(monkeypatch):# ── image generation: request modalities + response translation ──────-def test_image_model_sets_response_modalities(monkeypatch):- captured = _capture_body(- monkeypatch,- model = "gemini-2.5-flash-image",- enabled_tools = ["image_generation"],- )- assert captured["body"]["generationConfig"]["responseModalities"] == ["TEXT", "IMAGE"]--def test_image_generation_tool_sets_response_modalities_on_image_model(monkeypatch):"""`enabled_tools=["image_generation"]` flips responseModalitiesonly when the selected model is image-capable; otherwise thediff --git a/studio/backend/tests/test_gguf_metadata.py b/studio/backend/tests/test_gguf_metadata.pyindex db1dff0ae8f..63dcf00d497 100644--- a/studio/backend/tests/test_gguf_metadata.py+++ b/studio/backend/tests/test_gguf_metadata.py@@ -380,186 +380,162 @@ def test_is_mmproj_by_metadata_signals():# --- pairing_score ------------------------------------------------------def test_pairing_score_base_model_url_match():- weight = {- "general.base_model.0.repo_url": "https://huggingface.co/Qwen/Qwen3.5-9B",- }- mmproj = {- "general.base_model.0.repo_url": "https://huggingface.co/Qwen/Qwen3.5-9B",- }- assert pairing_score(weight, mmproj) == 100---def test_pairing_score_base_model_url_mismatch():- weight = {- "general.base_model.0.repo_url": "https://huggingface.co/Qwen/Qwen3.5-9B",- }- mmproj = {- "general.base_model.0.repo_url": "https://huggingface.co/google/gemma-3-9B",- }- assert pairing_score(weight, mmproj) == -1+def _md(+ url = None,+ basename = None,+ org = None,+):+ keys = (+ "general.base_model.0.repo_url",+ "general.basename",+ "general.base_model.0.organization",+ )+ return {k: v for k, v in zip(keys, (url, basename, org)) if v is not None}-def test_pairing_score_base_model_url_derivative_repack_match():- weight = {- "general.basename": "gemma-4-26B-A4B-it",- "general.base_model.0.repo_url": (- "https://huggingface.co/lmstudio-community/gemma-4-26B-A4B-it-GGUF"+# 100: same base repo, 90: derivative repo with matching basename, 80/60: basename fallbacks, -1: mismatch.+ "weight, mmproj, expected",+ [+ pytest.param(+ _md(url = "https://huggingface.co/Qwen/Qwen3.5-9B"),+ _md(url = "https://huggingface.co/Qwen/Qwen3.5-9B"),+ 100,+ id = "base_model_url_match",),- }- mmproj = {- "general.basename": "gemma-4-26B-A4B-it",- "general.base_model.0.repo_url": "https://huggingface.co/google/gemma-4-26B-A4B-it",- }- assert pairing_score(weight, mmproj) == 90---def test_pairing_score_base_model_url_derivative_quant_match():- weight = {- "general.basename": "gemma-4-26B-A4B-it",- "general.base_model.0.repo_url": (- "https://huggingface.co/vendor/gemma-4-26B-A4B-it-qat-q4_0-uncensored-heretic"+ pytest.param(+ _md(url = "https://huggingface.co/Qwen/Qwen3.5-9B"),+ _md(url = "https://huggingface.co/google/gemma-3-9B"),+ -1,+ id = "base_model_url_mismatch",),- }- mmproj = {- "general.basename": "gemma-4-26B-A4B-it",- "general.base_model.0.repo_url": "https://huggingface.co/google/gemma-4-26B-A4B-it",- }- assert pairing_score(weight, mmproj) == 90---def test_pairing_score_derivative_url_handles_non_hf_hosts():- weight = {- "general.basename": "Model-VL",- "general.base_model.0.repo_url": "https://github.com/acme/Model-VL-GGUF",- }- mmproj = {- "general.basename": "Model-VL",- "general.base_model.0.repo_url": "https://gitlab.example.com/acme/Model-VL",- }- assert pairing_score(weight, mmproj) == 90---def test_pairing_score_derivative_url_handles_nested_namespaces():- weight = {- "general.basename": "Model-VL",- "general.base_model.0.repo_url": ("https://gitlab.example.com/acme/models/Model-VL-GGUF"),- }- mmproj = {- "general.basename": "Model-VL",- "general.base_model.0.repo_url": "https://gitlab.example.com/acme/models/Model-VL",- }- assert pairing_score(weight, mmproj) == 90---def test_pairing_score_derivative_url_handles_bare_repo_ids():- weight = {- "general.basename": "Model-VL",- "general.base_model.0.repo_url": "acme/Model-VL-GGUF",- }- mmproj = {- "general.basename": "Model-VL",- "general.base_model.0.repo_url": "acme/Model-VL",- }- assert pairing_score(weight, mmproj) == 90---def test_pairing_score_derivative_url_handles_dotted_bare_owner():- weight = {- "general.basename": "Model",- "general.base_model.0.repo_url": "acme.ai/Model-GGUF",- }- mmproj = {- "general.basename": "Model",- "general.base_model.0.repo_url": "acme.ai/Model",- }- assert pairing_score(weight, mmproj) == 90---def test_pairing_score_derivative_url_rejects_basename_mismatch():- weight = {- "general.basename": "gemma-4-26B-A4B-it",- "general.base_model.0.repo_url": "https://huggingface.co/google/gemma-4-26B-A4B-it",- }- mmproj = {- "general.basename": "gemma-4-26B",- "general.base_model.0.repo_url": "https://huggingface.co/google/gemma-4-26B",- }- assert pairing_score(weight, mmproj) == -1---def test_pairing_score_base_model_url_trailing_slash_normalised():- weight = {- "general.base_model.0.repo_url": "https://huggingface.co/Qwen/Qwen3.5-9B/",- }- mmproj = {- "general.base_model.0.repo_url": "https://huggingface.co/Qwen/Qwen3.5-9B",- }- assert pairing_score(weight, mmproj) == 100---def test_pairing_score_base_model_url_scheme_and_git_normalised():- weight = {- "general.base_model.0.repo_url": "http://huggingface.co/Qwen/Qwen3.5-9B.GIT",- }- mmproj = {- "general.base_model.0.repo_url": "https://huggingface.co/Qwen/Qwen3.5-9B",- }- assert pairing_score(weight, mmproj) == 100---def test_pairing_score_hosted_and_bare_repo_ids_match():- weight = {- "general.base_model.0.repo_url": "https://huggingface.co/acme/Model",- }- mmproj = {- "general.base_model.0.repo_url": "acme/Model",- }- assert pairing_score(weight, mmproj) == 100---def test_pairing_score_non_hf_url_and_bare_repo_ids_do_not_match():- weight = {- "general.base_model.0.repo_url": "https://github.com/acme/Model",- }- mmproj = {- "general.base_model.0.repo_url": "acme/Model",- }- assert pairing_score(weight, mmproj) == -1---def test_pairing_score_derivative_url_requires_basename_evidence():- weight = {- "general.base_model.0.repo_url": "https://huggingface.co/vendor/model-v2-GGUF",- }- mmproj = {- "general.base_model.0.repo_url": "https://huggingface.co/vendor/model",- }- assert pairing_score(weight, mmproj) == -1---def test_pairing_score_rejects_arbitrary_slug_prefix():- weight = {- "general.base_model.0.repo_url": "https://huggingface.co/Qwen/Qwen3.5-9B",- "general.basename": "Qwen3.5",- }- mmproj = {- "general.base_model.0.repo_url": "https://huggingface.co/Qwen/Qwen3.5",- "general.basename": "Qwen3.5",- }- assert pairing_score(weight, mmproj) == -1---def test_pairing_score_rejects_qualifier_without_separator():- weight = {- "general.base_model.0.repo_url": "org/ModelGGUF",- "general.basename": "Model",- }- mmproj = {- "general.base_model.0.repo_url": "other/Model",- "general.basename": "Model",- }- assert pairing_score(weight, mmproj) == -1+ pytest.param(+ _md(+ url = "https://huggingface.co/lmstudio-community/gemma-4-26B-A4B-it-GGUF",+ basename = "gemma-4-26B-A4B-it",+ ),+ _md(+ url = "https://huggingface.co/google/gemma-4-26B-A4B-it",+ basename = "gemma-4-26B-A4B-it",+ ),+ 90,+ id = "base_model_url_derivative_repack_match",+ ),+ pytest.param(+ _md(+ url = "https://huggingface.co/vendor/gemma-4-26B-A4B-it-qat-q4_0-uncensored-heretic",+ basename = "gemma-4-26B-A4B-it",+ ),+ _md(+ url = "https://huggingface.co/google/gemma-4-26B-A4B-it",+ basename = "gemma-4-26B-A4B-it",+ ),+ 90,+ id = "base_model_url_derivative_quant_match",+ ),+ pytest.param(+ _md(url = "https://github.com/acme/Model-VL-GGUF", basename = "Model-VL"),+ _md(url = "https://gitlab.example.com/acme/Model-VL", basename = "Model-VL"),+ 90,+ id = "derivative_url_handles_non_hf_hosts",+ ),+ pytest.param(+ _md(url = "https://gitlab.example.com/acme/models/Model-VL-GGUF", basename = "Model-VL"),+ _md(url = "https://gitlab.example.com/acme/models/Model-VL", basename = "Model-VL"),+ 90,+ id = "derivative_url_handles_nested_namespaces",+ ),+ pytest.param(+ _md(url = "acme/Model-VL-GGUF", basename = "Model-VL"),+ _md(url = "acme/Model-VL", basename = "Model-VL"),+ 90,+ id = "derivative_url_handles_bare_repo_ids",+ ),+ pytest.param(+ _md(url = "acme.ai/Model-GGUF", basename = "Model"),+ _md(url = "acme.ai/Model", basename = "Model"),+ 90,+ id = "derivative_url_handles_dotted_bare_owner",+ ),+ pytest.param(+ _md(+ url = "https://huggingface.co/google/gemma-4-26B-A4B-it",+ basename = "gemma-4-26B-A4B-it",+ ),+ _md(url = "https://huggingface.co/google/gemma-4-26B", basename = "gemma-4-26B"),+ -1,+ id = "derivative_url_rejects_basename_mismatch",+ ),+ pytest.param(+ _md(url = "https://huggingface.co/Qwen/Qwen3.5-9B/"),+ _md(url = "https://huggingface.co/Qwen/Qwen3.5-9B"),+ 100,+ id = "base_model_url_trailing_slash_normalised",+ ),+ pytest.param(+ _md(url = "http://huggingface.co/Qwen/Qwen3.5-9B.GIT"),+ _md(url = "https://huggingface.co/Qwen/Qwen3.5-9B"),+ 100,+ id = "base_model_url_scheme_and_git_normalised",+ ),+ pytest.param(+ _md(url = "https://huggingface.co/acme/Model"),+ _md(url = "acme/Model"),+ 100,+ id = "hosted_and_bare_repo_ids_match",+ ),+ pytest.param(+ _md(url = "https://github.com/acme/Model"),+ _md(url = "acme/Model"),+ -1,+ id = "non_hf_url_and_bare_repo_ids_do_not_match",+ ),+ pytest.param(+ _md(url = "https://huggingface.co/vendor/model-v2-GGUF"),+ _md(url = "https://huggingface.co/vendor/model"),+ -1,+ id = "derivative_url_requires_basename_evidence",+ ),+ pytest.param(+ _md(url = "https://huggingface.co/Qwen/Qwen3.5-9B", basename = "Qwen3.5"),+ _md(url = "https://huggingface.co/Qwen/Qwen3.5", basename = "Qwen3.5"),+ -1,+ id = "rejects_arbitrary_slug_prefix",+ ),+ pytest.param(+ _md(url = "org/ModelGGUF", basename = "Model"),+ _md(url = "other/Model", basename = "Model"),+ -1,+ id = "rejects_qualifier_without_separator",+ ),+ pytest.param(+ _md(url = "https://git.example.com/Org/Model", basename = "Model"),+ _md(url = "https://git.example.com/org/model", basename = "Model"),+ -1,+ id = "preserves_case_sensitive_repo_paths",+ ),+ pytest.param(+ _md(url = "Org/Model", basename = "Model"),+ _md(url = "org/Model", basename = "Model"),+ -1,+ id = "preserves_case_sensitive_bare_repo_ids",+ ),+ pytest.param(+ _md(url = "https://huggingface.co/org/model", basename = "model"),+ _md(url = "https://huggingface.co/other/model-ft", basename = "model"),+ -1,+ id = "rejects_derivative_projector_for_base_weight",+ ),+ pytest.param(+ _md(basename = "Nanonets-Ocr-S", org = "Nanonets"),+ _md(basename = "Nanonets-Ocr-S", org = "Nanonets"),+ 80,+ id = "basename_plus_org_fallback",+ ),+ ],+)+def test_pairing_score(weight, mmproj, expected):+ assert pairing_score(weight, mmproj) == expected@pytest.mark.parametrize(@@ -616,54 +592,6 @@ def test_pairing_score_preserves_case_in_hf_file_paths():)-def test_pairing_score_preserves_case_sensitive_repo_paths():- weight = {- "general.base_model.0.repo_url": "https://git.example.com/Org/Model",- "general.basename": "Model",- }- mmproj = {- "general.base_model.0.repo_url": "https://git.example.com/org/model",- "general.basename": "Model",- }- assert pairing_score(weight, mmproj) == -1---def test_pairing_score_preserves_case_sensitive_bare_repo_ids():- weight = {- "general.base_model.0.repo_url": "Org/Model",- "general.basename": "Model",- }- mmproj = {- "general.base_model.0.repo_url": "org/Model",- "general.basename": "Model",- }- assert pairing_score(weight, mmproj) == -1---def test_pairing_score_rejects_derivative_projector_for_base_weight():- weight = {- "general.basename": "model",- "general.base_model.0.repo_url": "https://huggingface.co/org/model",- }- mmproj = {- "general.basename": "model",- "general.base_model.0.repo_url": "https://huggingface.co/other/model-ft",- }- assert pairing_score(weight, mmproj) == -1---def test_pairing_score_basename_plus_org_fallback():- weight = {- "general.basename": "Nanonets-Ocr-S",- "general.base_model.0.organization": "Nanonets",- }- mmproj = {- "general.basename": "Nanonets-Ocr-S",- "general.base_model.0.organization": "Nanonets",- }- assert pairing_score(weight, mmproj) == 80--def test_pairing_score_basename_only_fallback():assert (pairing_score(diff --git a/studio/backend/tests/test_gpu_arch_gate_7624.py b/studio/backend/tests/test_gpu_arch_gate_7624.pyindex cf16eb5fce8..6a792dac000 100644--- a/studio/backend/tests/test_gpu_arch_gate_7624.py+++ b/studio/backend/tests/test_gpu_arch_gate_7624.py@@ -492,21 +492,6 @@ class TestArchCrashRetrySet:)assert LlamaCppBackend._arch_crash_retry_gpu_ids([0, 1], [0, 1]) == []- def test_single_gpu_host_has_no_retry(self, monkeypatch):- """#7624: the one selected GPU IS the whole host, so the narrowing must be- skipped outright. The spy counts rather than raises: the branch runs under- ``except Exception: return []``, which would swallow an AssertionError and- return the very [] the guard should produce, passing either way."""- calls = []-- def _spy():- calls.append(1)- return set()-- monkeypatch.setattr(LlamaCppBackend, "_rocm_unified_memory_gpu_ids", staticmethod(_spy))- assert LlamaCppBackend._arch_crash_retry_gpu_ids([0], [0]) == []- assert calls == [], "single-GPU host must not reach the unified-memory probe"-def test_empty_selection_is_a_no_op(self):assert LlamaCppBackend._arch_crash_retry_gpu_ids([], [0, 1]) == []diff --git a/studio/backend/tests/test_gpu_selection.py b/studio/backend/tests/test_gpu_selection.pyindex b08232e535a..2cf52062712 100644--- a/studio/backend/tests/test_gpu_selection.py+++ b/studio/backend/tests/test_gpu_selection.py@@ -2596,10 +2596,6 @@ class TestTheCudaMapNamesItsFallback(_GpuCacheResetMixin, unittest.TestCase):with patch("utils.hardware.hardware.get_device", return_value = DeviceType.CUDA):self.assertNotEqual(get_device_map([0, 1]), "unsloth")- def test_xpu_keeps_plain_balanced(self):- with patch("utils.hardware.hardware.get_device", return_value = DeviceType.XPU):- self.assertEqual(get_device_map([0, 1]), "balanced")-def test_a_single_gpu_never_asks_for_a_plan(self):for device in (DeviceType.CUDA, DeviceType.XPU, DeviceType.CPU):with patch("utils.hardware.hardware.get_device", return_value = device):diff --git a/studio/backend/tests/test_hub_download_ambient_token.py b/studio/backend/tests/test_hub_download_ambient_token.pyindex 3aa9d079ac2..e0c2a56e397 100644--- a/studio/backend/tests/test_hub_download_ambient_token.py+++ b/studio/backend/tests/test_hub_download_ambient_token.py@@ -25,7 +25,6 @@ from auth.authentication import ()from hub.routes import datasets as datasets_routesfrom hub.routes import inventory as inventory_routes-from hub.dependencies import get_request_hf_tokenfrom hub.services import download_lifecyclefrom hub.services.datasets import downloads as dataset_downloadsfrom hub.services.models import downloads as model_downloads@@ -97,25 +96,6 @@ def test_only_a_ui_session_may_borrow_the_backend_token(via_api_key, expected):assert asyncio.run(allow_ambient_hf_token(via_api_key = via_api_key)) is expected- "hf_token, allow_ambient, expected",- [- (None, False, False),- (None, True, None),- ("request-token", False, "request-token"),- (" request-token ", True, "request-token"),- ],-)-def test_request_metadata_token_keeps_the_caller_boundary(hf_token, allow_ambient, expected):- resolved = get_request_hf_token(- hf_token = hf_token,- allow_ambient_token = allow_ambient,- )- assert resolved == expected- if expected in (None, False):- assert resolved is expected--@pytest.mark.parametrize("via_api_key, expected", [(True, False), (False, None)])def test_gguf_metadata_route_does_not_lend_api_keys_the_backend_token(monkeypatch, via_api_key, expecteddiff --git a/studio/backend/tests/test_index_bootstrap_origin_extra.py b/studio/backend/tests/test_index_bootstrap_origin_extra.pyindex e1c52a653ea..9c09b25d6c6 100644--- a/studio/backend/tests/test_index_bootstrap_origin_extra.py+++ b/studio/backend/tests/test_index_bootstrap_origin_extra.py@@ -9,6 +9,8 @@ Companion to ``test_index_bootstrap_origin.py``: IPv6 netlocs, opaque originsfrom unittest.mock import MagicMock+import pytest+def _build_request(host: str,@@ -22,168 +24,110 @@ def _build_request(return request-# ── IPv6 ────────────────────────────────────────────────────────────---def test_is_same_origin_request_ipv6_loopback_same_origin():- """Unsloth supports ``-H ::1`` binds; netloc is ``[::1]:8902``. Bare- ``partition(":")`` mis-parses the bracketed form and would refuse the- bootstrap on legitimate same-origin navigation.- """- from main import _is_same_origin_request-- req = _build_request("[::1]:8902", origin = "http://[::1]:8902")- assert _is_same_origin_request(req) is True---def test_is_same_origin_request_ipv6_full_address_same_origin():- from main import _is_same_origin_request- req = _build_request(- "[2001:db8::1]:8443",- origin = "https://[2001:db8::1]:8443",- scheme = "https",- )- assert _is_same_origin_request(req) is True---def test_is_same_origin_request_ipv6_default_port_stripped():- """Browser drops :80 on ``http://[::1]``."""- from main import _is_same_origin_request-- req = _build_request("[::1]:80", origin = "http://[::1]")- assert _is_same_origin_request(req) is True---def test_is_same_origin_request_ipv6_case_insensitive():- """Hex digits in IPv6 are case-insensitive per RFC 5952."""- from main import _is_same_origin_request-- req = _build_request(- "[2001:DB8::1]:8443",- origin = "https://[2001:db8::1]:8443",- scheme = "https",- )- assert _is_same_origin_request(req) is True---def test_is_same_origin_request_ipv6_different_host_cross_origin():- from main import _is_same_origin_request- req = _build_request("[::1]:8902", origin = "http://[2001:db8::1]:8902")- assert _is_same_origin_request(req) is False---def test_is_same_origin_request_ipv6_port_mismatch_cross_origin():- from main import _is_same_origin_request- req = _build_request("[::1]:8902", origin = "http://[::1]:9999")- assert _is_same_origin_request(req) is False---def test_is_same_origin_request_ipv6_userinfo_stripped():- from main import _is_same_origin_request- req = _build_request("user:pass@[::1]:8902", origin = "http://[::1]:8902")- assert _is_same_origin_request(req) is True---# ── Opaque origins (data:, blob:) ───────────────────────────────────---def test_is_same_origin_request_data_url_origin_is_cross_origin():- """``data:`` URLs are opaque origins (HTML living standard); no host, never same-origin."""- from main import _is_same_origin_request-- req = _build_request("127.0.0.1:8902", origin = "data:text/html,<script>alert(1)</script>")- assert _is_same_origin_request(req) is False---def test_is_same_origin_request_blob_url_origin_is_cross_origin():- """``blob:`` URLs carry the inner origin only in non-canonical form; the canonical comparison rejects them."""- from main import _is_same_origin_request-- req = _build_request("127.0.0.1:8902", origin = "blob:http://127.0.0.1:8902/uuid")- assert _is_same_origin_request(req) is False---def test_is_same_origin_request_file_url_origin_is_cross_origin():- """``file://`` pages usually send ``Origin: null``; older engines sent- ``Origin: file://``. Neither is same-origin vs an http listener.- """- from main import _is_same_origin_request-- req = _build_request("127.0.0.1:8902", origin = "file://")- assert _is_same_origin_request(req) is False---# ── Multi-Origin header (comma-joined by Starlette) ────────────────---def test_is_same_origin_request_comma_joined_origins_cross_origin():- """Starlette joins repeated headers with ``, ``; the canonical parser can't- safely split this, so it falls to cross-origin.- """- from main import _is_same_origin_request-- req = _build_request(- "127.0.0.1:8902",- origin = "http://127.0.0.1:8902, http://evil.example",- )- assert _is_same_origin_request(req) is False---# ── localhost vs 127.0.0.1 (distinct origins per web platform) ──────---def test_is_same_origin_request_localhost_vs_127_is_cross_origin():- """Browsers treat ``localhost`` and ``127.0.0.1`` as distinct origins; the- canonical comparison must not DNS-collapse them.- """- from main import _is_same_origin_request-- req = _build_request("127.0.0.1:8902", origin = "http://localhost:8902")- assert _is_same_origin_request(req) is False---def test_is_same_origin_request_127_vs_localhost_is_cross_origin():- from main import _is_same_origin_request- req = _build_request("localhost:8902", origin = "http://127.0.0.1:8902")- assert _is_same_origin_request(req) is False---# ── urlparse ValueError robustness ─────────────────────────────────---def test_is_same_origin_request_malformed_ipv6_bracket_is_cross_origin():- """``urlparse`` raises ``ValueError('Invalid IPv6 URL')`` on unclosed- brackets (CVE-2024-11168 hardening). The gate must swallow it and fall to- cross-origin rather than 500 the SPA handler.- """- from main import _is_same_origin_request-- req = _build_request("127.0.0.1:8902", origin = "http://[malformed")- assert _is_same_origin_request(req) is False---def test_is_same_origin_request_invalid_ipv6_address_is_cross_origin():- """Bracketed but invalid IPv6 (e.g. ``[::g]``) also raises- ``ValueError`` inside ``urlparse``."""- from main import _is_same_origin_request-- req = _build_request("127.0.0.1:8902", origin = "http://[::g]:8902")- assert _is_same_origin_request(req) is False---def test_is_same_origin_request_bracket_with_trailing_garbage_is_cross_origin():- """Text after the closing bracket also raises inside ``urlparse``."""- from main import _is_same_origin_request-- req = _build_request("127.0.0.1:8902", origin = "http://[2001:db8::1]extra:8902")- assert _is_same_origin_request(req) is False---def test_is_same_origin_request_empty_origin_header_is_cross_origin():- """Explicit empty ``Origin:`` is not a valid serialised origin and must not- be conflated with a missing header; cross-origin, bootstrap withheld.- """- from main import _is_same_origin_request-- req = _build_request("127.0.0.1:8902", origin = "")- assert _is_same_origin_request(req) is False+ "host, origin, scheme, same",+ [+ # IPv6: ``-H ::1`` binds give a bracketed netloc that a bare ``partition(":")`` mis-parses.+ pytest.param(+ "[::1]:8902", "http://[::1]:8902", "http", True, id = "ipv6_loopback_same_origin"+ ),+ pytest.param(+ "[2001:db8::1]:8443",+ "https://[2001:db8::1]:8443",+ "https",+ True,+ id = "ipv6_full_address_same_origin",+ ),+ pytest.param("[::1]:80", "http://[::1]", "http", True, id = "ipv6_default_port_stripped"),+ # Hex digits in IPv6 are case-insensitive per RFC 5952.+ pytest.param(+ "[2001:DB8::1]:8443",+ "https://[2001:db8::1]:8443",+ "https",+ True,+ id = "ipv6_case_insensitive",+ ),+ pytest.param(+ "[::1]:8902",+ "http://[2001:db8::1]:8902",+ "http",+ False,+ id = "ipv6_different_host_cross_origin",+ ),+ pytest.param(+ "[::1]:8902", "http://[::1]:9999", "http", False, id = "ipv6_port_mismatch_cross_origin"+ ),+ pytest.param(+ "user:pass@[::1]:8902", "http://[::1]:8902", "http", True, id = "ipv6_userinfo_stripped"+ ),+ # Opaque origins have no host, so they are never same-origin; ``file://`` is what older engines sent.+ pytest.param(+ "127.0.0.1:8902",+ "data:text/html,<script>alert(1)</script>",+ "http",+ False,+ id = "data_url_origin_is_cross_origin",+ ),+ pytest.param(+ "127.0.0.1:8902",+ "blob:http://127.0.0.1:8902/uuid",+ "http",+ False,+ id = "blob_url_origin_is_cross_origin",+ ),+ pytest.param(+ "127.0.0.1:8902", "file://", "http", False, id = "file_url_origin_is_cross_origin"+ ),+ # Starlette joins repeated headers with ``, ``, which cannot be split safely.+ pytest.param(+ "127.0.0.1:8902",+ "http://127.0.0.1:8902, http://evil.example",+ "http",+ False,+ id = "comma_joined_origins_cross_origin",+ ),+ # Browsers treat ``localhost`` and ``127.0.0.1`` as distinct origins: no DNS collapse.+ pytest.param(+ "127.0.0.1:8902",+ "http://localhost:8902",+ "http",+ False,+ id = "localhost_vs_127_is_cross_origin",+ ),+ pytest.param(+ "localhost:8902",+ "http://127.0.0.1:8902",+ "http",+ False,+ id = "127_vs_localhost_is_cross_origin",+ ),+ # ``urlparse`` raises ValueError on these (CVE-2024-11168 hardening); the gate must+ # swallow it and refuse rather than 500 the SPA handler.+ pytest.param(+ "127.0.0.1:8902",+ "http://[malformed",+ "http",+ False,+ id = "malformed_ipv6_bracket_is_cross_origin",+ ),+ pytest.param(+ "127.0.0.1:8902",+ "http://[::g]:8902",+ "http",+ False,+ id = "invalid_ipv6_address_is_cross_origin",+ ),+ pytest.param(+ "127.0.0.1:8902",+ "http://[2001:db8::1]extra:8902",+ "http",+ False,+ id = "bracket_with_trailing_garbage_is_cross_origin",+ ),+ # An explicit empty Origin is not a missing header.+ pytest.param("127.0.0.1:8902", "", "http", False, id = "empty_origin_header_is_cross_origin"),+ ],+)+def test_is_same_origin_request(host, origin, scheme, same):+ from main import _is_same_origin_request+ assert _is_same_origin_request(_build_request(host, origin, scheme)) is samediff --git a/studio/backend/tests/test_launch_reasoning_flag.py b/studio/backend/tests/test_launch_reasoning_flag.pyindex 6b0e251b21d..08ae0d5b1d3 100644--- a/studio/backend/tests/test_launch_reasoning_flag.py+++ b/studio/backend/tests/test_launch_reasoning_flag.py@@ -209,13 +209,6 @@ class TestOnlyTheDeprecatedKeyMoves:"""assert _build_launch_reasoning_args(caps, {}) == ["--chat-template-kwargs", "{}"]- def test_an_empty_remainder_after_the_flag_appends_nothing(self):- """The other side of it: that argument did not exist on main either."""- assert _build_launch_reasoning_args(MODERN_CAPS, {"enable_thinking": True}) == [- "--reasoning",- "on",- ]-# enable_thinking style, with preserve_thinking so both channels are exercised at once.THINKING_TEMPLATE = (diff --git a/studio/backend/tests/test_llama_admission_unstated_max_tokens.py b/studio/backend/tests/test_llama_admission_unstated_max_tokens.pyindex b6f408fd7e3..c97cd30a258 100644--- a/studio/backend/tests/test_llama_admission_unstated_max_tokens.py+++ b/studio/backend/tests/test_llama_admission_unstated_max_tokens.py@@ -266,17 +266,6 @@ class TestTheAllowanceCannotExceedOneSlot:== 0)- def test_a_short_prompt_still_gets_the_full_allowance(self):- assert (- _openai_llama_admission_output_allowance(- self.WINDOW,- budget = self.BUDGET,- prompt_tokens = 100,- context_window = self.WINDOW,- )- == _OPENAI_LLAMA_ADMISSION_UNSTATED_OUTPUT_TOKENS- )-def test_unified_is_unchanged(self):"""window == budget there, so this clamp is the same arithmetic it always was."""assert (diff --git a/studio/backend/tests/test_mcp_stdio_node_path.py b/studio/backend/tests/test_mcp_stdio_node_path.pyindex 921dd0ef341..88d1a0bbbd7 100644--- a/studio/backend/tests/test_mcp_stdio_node_path.py+++ b/studio/backend/tests/test_mcp_stdio_node_path.py@@ -477,12 +477,6 @@ def test_managed_node_used_when_system_lacks_npx(managed_node_install, monkeypatassert node_runtime.path_with_managed_node(str(sysbin)) == expected-def test_complete_system_runtime_is_not_shadowed(managed_node_install, monkeypatch, tmp_path):- sysbin = _system_node_dir(tmp_path)- _patch_floors(monkeypatch, lambda executable, path = None: True)- assert node_runtime.path_with_managed_node(str(sysbin)) == str(sysbin)--def test_shadowed_managed_dir_moves_to_front(managed_node_install, monkeypatch, tmp_path):"""Already on PATH but behind a stale runtime: it has to move up, not stay put."""stale = _system_node_dir(tmp_path)diff --git a/studio/backend/tests/test_metal_explicit_context_guard.py b/studio/backend/tests/test_metal_explicit_context_guard.pyindex f2affa033c6..e8f0dfc8341 100644--- a/studio/backend/tests/test_metal_explicit_context_guard.py+++ b/studio/backend/tests/test_metal_explicit_context_guard.py@@ -643,12 +643,6 @@ class TestAContextAboveTheModelsNativeLength:out = self._above(tmp_path, monkeypatch, n_ctx = self._ASKED, kv_per_token = 1024)assert out["backend"].max_context_length <= self._ASKED- def test_a_refused_request_does_not_raise_the_published_bound(self, tmp_path, monkeypatch):- """Only an accepted ceiling is published. A refusal measured nothing it can- stand behind at the request, so the bound stays where the cap left it."""- with pytest.raises(RuntimeError, match = "unified"):- self._above(tmp_path, monkeypatch, n_ctx = self._ASKED, kv_per_token = _FAT_KV)-def test_the_pass_through_spelling_launches_too(self, tmp_path, monkeypatch):"""The spelling a RoPE-scaled request actually arrives in."""cmd = self._above(diff --git a/studio/backend/tests/test_mla_kv_cache_symmetry.py b/studio/backend/tests/test_mla_kv_cache_symmetry.pyindex d914cb5965e..7b49db14534 100644--- a/studio/backend/tests/test_mla_kv_cache_symmetry.py+++ b/studio/backend/tests/test_mla_kv_cache_symmetry.py@@ -339,10 +339,6 @@ class TestTheDraftSignalComesFromTheLaunchCommand:env = {"LLAMA_ARG_SPEC_DRAFT_MODEL": "/d/mla.gguf"}assert b._draft_kv_symmetry(["llama-server"], env) is True- def test_no_drafter_at_all_is_none(self):- b = self._backend({})- assert b._draft_kv_symmetry(["llama-server", "-m", "t.gguf"], {}) is None-def test_an_unreadable_drafter_takes_the_conservative_path(self):"""Named but unreadable is still a drafter that will launch."""b = self._backend({})diff --git a/studio/backend/tests/test_mtp_drafter_companion.py b/studio/backend/tests/test_mtp_drafter_companion.pyindex 3662454d520..f52b2ea8b7d 100644--- a/studio/backend/tests/test_mtp_drafter_companion.py+++ b/studio/backend/tests/test_mtp_drafter_companion.py@@ -2854,14 +2854,6 @@ def test_detect_dflash_file_ignores_the_suffix_form_the_picker_cannot_hide(tmp_passert _is_companion_gguf_path("dflash-kquant.gguf") is True-def test_dflash_prefix_form_is_still_found_beside_the_weight(tmp_path):- """Dropping the suffix form must not cost the published sidecar."""- weight = _write_gguf(tmp_path / "Muse-Glimmer-30B-UD-Q4_K_XL.gguf", "muse-glimmer")- sidecar = _write_gguf(tmp_path / "dflash-kquant.gguf", "dflash")-- assert detect_dflash_file(str(weight)) == str(sidecar.resolve())--def test_detect_dflash_file_validates_a_candidate_before_reading_its_header(tmp_path, monkeypatch):"""A native grant answers through ``accept``, and its answer has to arrivebefore the file is opened.diff --git a/studio/backend/tests/test_native_context_length.py b/studio/backend/tests/test_native_context_length.pyindex 069d451e8f0..e1a88d0fada 100644--- a/studio/backend/tests/test_native_context_length.py+++ b/studio/backend/tests/test_native_context_length.py@@ -567,12 +567,6 @@ class TestNativeContextEdgeCases:class TestCrossPlatform:"""Binary I/O and serialization correctness across platforms."""- def test_le_uint32_context_length(self, tmp_path, backend):- """Little-endian UINT32 parsed correctly."""- path = make_gguf(tmp_path, "llama", [("context_length", 16384, 4)])- backend._read_gguf_metadata(path)- assert backend.native_context_length == 16384-def test_le_uint64_context_length(self, tmp_path, backend):"""Little-endian UINT64 parsed correctly."""path = make_gguf(tmp_path, "llama", [("context_length", 16384, 10)])diff --git a/studio/backend/tests/test_openai_passthrough_respawn.py b/studio/backend/tests/test_openai_passthrough_respawn.pyindex d24c1716188..09323ea922e 100644--- a/studio/backend/tests/test_openai_passthrough_respawn.py+++ b/studio/backend/tests/test_openai_passthrough_respawn.py@@ -33,7 +33,6 @@ from routes.inference import (_is_lost_upstream_connection,_openai_passthrough_non_streaming_upstream,_openai_passthrough_stream_admitted,- _passthrough_retry_url,)_DEAD = "http://127.0.0.1:57953"@@ -180,20 +179,6 @@ async def _run_stream(backend, lease = None):return "".join(chunks)-# ── Helper ────────────────────────────────────────────────────---def test_the_retry_url_is_shared_with_the_anthropic_surface():- """Both passthroughs post to the same upstream route, so one helper serves both.- A rename that leaves this surface behind is the bug being fixed."""- backend = _Backend()-- url = asyncio.run(_passthrough_retry_url(backend, httpx.ConnectError("x")))-- assert url == f"{_FRESH}/v1/chat/completions"- assert backend.respawn_calls == 1--# ── Non-streaming ─────────────────────────────────────────────diff --git a/studio/backend/tests/test_passthrough_healing.py b/studio/backend/tests/test_passthrough_healing.pyindex bba89f3f4be..cc4c6251c54 100644--- a/studio/backend/tests/test_passthrough_healing.py+++ b/studio/backend/tests/test_passthrough_healing.py@@ -1598,16 +1598,6 @@ class TestHealerSignalAlignment:there; ungated in the healer it would stall legitimate prose untilfinalization without ever producing a promotable call."""- def test_heal_signals_are_promotable_formats_only(self):- from core.inference.passthrough_healing import _HEAL_SIGNALS- assert set(_HEAL_SIGNALS) == {- "<tool_call>",- "<|tool_call>",- "<function=",- "[TOOL_CALLS]",- "<|content_invoke_tool_json|>",- }-def test_prose_with_bare_args_marker_streams_through(self):healer = StreamToolCallHealer({"Bash"})chunks = [diff --git a/studio/backend/tests/test_picker_service.py b/studio/backend/tests/test_picker_service.pyindex d3919914597..230512c7c4e 100644--- a/studio/backend/tests/test_picker_service.py+++ b/studio/backend/tests/test_picker_service.py@@ -201,10 +201,11 @@ def test_processor_json_over_size_limit_is_skipped_not_parsed(tmp_path):def test_tokenizer_config_at_size_limit_is_still_read(tmp_path):- # A normal-sized config is unaffected by the bound (regression guard).- (tmp_path / "tokenizer_config.json").write_text(- json.dumps({"chat_template": "FROM_CONFIG"}), encoding = "utf-8"- )+ # The bound is inclusive: a file of exactly MAX_TEMPLATE_METADATA_BYTES is read.+ body = json.dumps({"chat_template": "FROM_CONFIG", "_pad": ""})+ body = body[:-2] + "x" * (MAX_TEMPLATE_METADATA_BYTES - len(body)) + body[-2:]+ assert len(body.encode("utf-8")) == MAX_TEMPLATE_METADATA_BYTES+ (tmp_path / "tokenizer_config.json").write_text(body, encoding = "utf-8", newline = "")assert _chat_template_from_tokenizer_dir(tmp_path) == "FROM_CONFIG"diff --git a/studio/backend/tests/test_pr5624_regressions.py b/studio/backend/tests/test_pr5624_regressions.pyindex f3c7ca1f3b1..f0a07be910b 100644--- a/studio/backend/tests/test_pr5624_regressions.py+++ b/studio/backend/tests/test_pr5624_regressions.py@@ -156,15 +156,6 @@ def test_glm_4_7_no_newlines_multi_call():assert calls[1]["function"]["name"] == "b"-def test_glm_4_7_does_not_break_qwen_path():- """Qwen ``<tool_call>{json}`` still dispatches to Qwen; GLM's- first-char ``[^\\n<{]`` excludes ``{``."""- text = '<tool_call>{"name":"web_search","arguments":{"q":"x"}}</tool_call>'- calls = parse_tool_calls_from_text(text)- assert len(calls) == 1- assert calls[0]["function"]["name"] == "web_search"--# Kimi K2 dotted name + bare counter (finding C in plan)diff --git a/studio/backend/tests/test_research_runs_hardening.py b/studio/backend/tests/test_research_runs_hardening.pyindex 2e8e7e83116..fd104790919 100644--- a/studio/backend/tests/test_research_runs_hardening.py+++ b/studio/backend/tests/test_research_runs_hardening.py@@ -628,17 +628,6 @@ def test_a_client_resolved_ceiling_is_used_verbatim(monkeypatch):assert _synthesis_max_tokens(inference) == 65_536-def test_a_ceiling_below_the_default_is_respected(monkeypatch):- monkeypatch.setattr(research_runs.providers_db, "get_provider", lambda _id: None)- inference = {- "providerType": "openai",- "providerId": "p1",- "maxOutputTokens": 8_192,- "maxOutputTokensPublished": 8_192,- }- assert _synthesis_max_tokens(inference) == 8_192--def test_a_legacy_ceiling_below_the_default_keeps_the_old_budget(monkeypatch):monkeypatch.setattr(research_runs.providers_db, "get_provider", lambda _id: None)inference = {"providerType": "openai", "providerId": "p1", "maxOutputTokens": 8_192}diff --git a/studio/backend/tests/test_research_runs_storage.py b/studio/backend/tests/test_research_runs_storage.pyindex 614b6a556ba..de1a60d0187 100644--- a/studio/backend/tests/test_research_runs_storage.py+++ b/studio/backend/tests/test_research_runs_storage.py@@ -3514,55 +3514,6 @@ def test_stream_line_wait_is_interruptible_by_cancellation(research_home):assert iterator_cancelled["value"] is True-def test_stream_open_wait_is_interruptible_by_cancellation(research_home, monkeypatch):- supervisor, worker = _shared_setup_1()- run = research_db.claim_next(supervisor.worker_id)- request_cancelled = {"value": False}- in_flight = asyncio.Event()-- class FakeClient:- def __init__(self, **kwargs):- pass-- async def __aenter__(self):- return self-- async def __aexit__(self, exc_type, exc, tb):- return False-- def build_request(self, *args, **kwargs):- return object()-- async def send(self, request, *, stream):- in_flight.set()- try:- await asyncio.Event().wait()- finally:- request_cancelled["value"] = True-- monkeypatch.setattr(worker.httpx, "AsyncClient", FakeClient)- monkeypatch.setattr(- worker.auth_storage,- "create_api_key",- lambda **kwargs: ("internal-key", {"id": 1}),- )- monkeypatch.setattr(worker.auth_storage, "revoke_internal_api_key", lambda key_id: True)-- async def scenario():- task = asyncio.create_task(- supervisor._stream_completion(run, [{"role": "user", "content": "question"}])- )- # Wait for the request to actually be in flight rather than guessing how- # long that takes: cancelling before it starts tests nothing.- await asyncio.wait_for(in_flight.wait(), timeout = _CANCEL_TIMEOUT_S)- supervisor.cancel("run-1")- with pytest.raises(worker.RunCancelled):- await asyncio.wait_for(task, timeout = _CANCEL_TIMEOUT_S)-- asyncio.run(scenario())- assert request_cancelled["value"] is True--def test_route_maps_unstable_assistant_conflict_to_409(research_home):from fastapi import HTTPExceptionfrom routes.research_runs import CreateResearchRun, create_research_rundiff --git a/studio/backend/tests/test_safetensors_tool_loop.py b/studio/backend/tests/test_safetensors_tool_loop.pyindex 38c929328e7..5279c85aad8 100644--- a/studio/backend/tests/test_safetensors_tool_loop.py+++ b/studio/backend/tests/test_safetensors_tool_loop.py@@ -5079,12 +5079,6 @@ class TestEnabledToolNameGate:def _names(self, calls):return [c["function"]["name"] for c in calls]- def test_parse_inactive_rehearsal_does_not_swallow_active_call(self):- text = 'foo[ARGS]{"a":1} web_search[ARGS]{"query":"cats"}'- calls = parse_tool_calls_from_text(text, enabled_tool_names = {"web_search"})- assert self._names(calls) == ["web_search"]- assert json.loads(calls[0]["function"]["arguments"]) == {"query": "cats"}-def test_parse_inactive_rehearsal_alone_is_prose(self):assert (parse_tool_calls_from_text('foo[ARGS]{"a":1}', enabled_tool_names = {"web_search"}) == []diff --git a/studio/backend/tests/test_training_finetune_targets.py b/studio/backend/tests/test_training_finetune_targets.pyindex 17b24662deb..9f1aa07d2bf 100644--- a/studio/backend/tests/test_training_finetune_targets.py+++ b/studio/backend/tests/test_training_finetune_targets.py@@ -197,8 +197,3 @@ def test_cuda_rejects_empty_layer_family():with pytest.raises(ValueError, match = "Nothing to train"):_check_finetune_targets_after_detect(_Trainer(is_vlm = True), config)---def test_cuda_text_run_is_untouched_by_either_guard():- from core.training.worker import _check_finetune_targets_after_detect- _check_finetune_targets_after_detect(_Trainer(), _config(**_ALL_OFF))diff --git a/studio/backend/tests/test_training_gpu_arch_gate.py b/studio/backend/tests/test_training_gpu_arch_gate.pyindex ac8fbaa7880..bbd0303a395 100644--- a/studio/backend/tests/test_training_gpu_arch_gate.py+++ b/studio/backend/tests/test_training_gpu_arch_gate.py@@ -127,14 +127,6 @@ class TestTheReportedHost:assert rocm_gpu_ids_without_torch_kernels() == {1}-class TestHsaOverrideKeepsWorking:- """The override makes a device PRESENT a supported arch; reading silicon breaks it."""-- def test_a_spoofed_device_is_kept(self, monkeypatch, no_mask):- _install(monkeypatch, _fake_torch([_props("gfx1101"), _props("gfx1100")]))- assert rocm_gpu_ids_without_torch_kernels() == set()--class TestArchSpellings:"""Reading only gcnArchName makes the gate a no-op on AMD SDK wheels."""diff --git a/studio/backend/tests/test_video_pr9057_simulation.py b/studio/backend/tests/test_video_pr9057_simulation.pyindex 80996739343..508fa314d81 100644--- a/studio/backend/tests/test_video_pr9057_simulation.py+++ b/studio/backend/tests/test_video_pr9057_simulation.py@@ -387,16 +387,6 @@ def test_a_long_multi_turn_thread_only_carries_one_clip():assert injected[0]["content"][0]["text"] == "last"-def test_the_part_shape_is_exactly_what_llama_server_parses():- messages = [{"role": "user", "content": "x"}]- _inject_video_part(messages, "PAYLOAD")- part = messages[0]["content"][-1]- assert set(part) == {"type", "input_video"}- assert part["type"] == "input_video"- assert set(part["input_video"]) == {"data"}- assert part["input_video"]["data"] == "PAYLOAD"--# --------------------------------------------------------------------------# E. the refusal paths, read off the handler# --------------------------------------------------------------------------@@ -426,18 +416,3 @@ def _routes_source() -> str:)def test_every_path_that_cannot_serve_a_clip_refuses_out_loud(needle):assert needle in _routes_source()---def test_the_size_check_is_paid_before_the_model_switch_not_after():- src = _routes_source()- handler = src.index("_needs_image = bool(_pre_parsed[2])")- assert src.index("_request_video_rejection(payload)", handler) < src.index(- "await _maybe_auto_switch_model(", handler- )---def test_the_external_provider_refusal_precedes_the_proxy_call():- src = _routes_source()- start = src.index("if payload.provider_id or payload.provider_type:")- branch = src[start : src.index("_proxy_to_external_provider(payload", start)]- assert "_request_has_video(payload)" in branchdiff --git a/tests/security/test_custom_dtype_no_eval.py b/tests/security/test_custom_dtype_no_eval.pyindex 584da623208..cbe420e14ad 100644--- a/tests/security/test_custom_dtype_no_eval.py+++ b/tests/security/test_custom_dtype_no_eval.py@@ -128,11 +128,6 @@ def test_an_inherited_value_that_mimics_ours_is_still_not_trusted(monkeypatch):assert not trusted-def test_unset_is_empty(monkeypatch):- monkeypatch.delenv("UNSLOTH_FORCE_CUSTOM_DTYPE", raising = False)- assert trusted_custom_dtype() == ("", False)--# --- vision.py no longer evaluates the fields --------------------------------diff --git a/tests/studio/install/test_cuda_repair.py b/tests/studio/install/test_cuda_repair.pyindex 255babd7770..f3a6826ee16 100644--- a/tests/studio/install/test_cuda_repair.py+++ b/tests/studio/install/test_cuda_repair.py@@ -1680,17 +1680,6 @@ class TestAnExplicitPinOutranksTheManifest:assert ok is Truemock_pip.assert_not_called()- def test_an_unrecognised_pin_still_falls_through_to_the_manifest(self):- # A /simple mirror names no family; the caller's unknown-pin gate is the guard.- ok, mock_pip = _run_flavor_invariant(- installed = "2.11.0+cpu",- expected_env = None,- recorded = "cu124",- index_url = "https://mirror.corp.example/simple",- )- assert ok is True- mock_pip.assert_not_called()-def test_the_setup_handover_still_wins_over_a_pin(self):# The handover describes the run that just installed; the pin may predate it.ok, mock_pip = _run_flavor_invariant(@@ -1744,17 +1733,6 @@ class TestExplicitlyPinnedGpuFlavorsAreStillEnforced:assert ok is Trueassert pin in mock_pip.call_args[0]- def test_an_unknown_pin_is_still_left_alone(self):- """Regression guard: narrowing the veto must not reopen the case it closed."""- ok, mock_pip = _run_flavor_invariant(- installed = "2.11.0+cpu",- expected_env = None,- recorded = "cu124",- index_url = "https://mirror.corp.example/simple",- )- assert ok is True- mock_pip.assert_not_called()-class TestSetupPs1CudaOnDiskFallback:"""A wedged NVIDIA driver hangs or faults `import torch` exactly as a faulted HIPdiff --git a/tests/studio/install/test_missing_kernel_arch_routing_9396.py b/tests/studio/install/test_missing_kernel_arch_routing_9396.pyindex d024533925d..b1a234e2f52 100644--- a/tests/studio/install/test_missing_kernel_arch_routing_9396.py+++ b/tests/studio/install/test_missing_kernel_arch_routing_9396.py@@ -220,12 +220,6 @@ def test_the_hardware_is_probed_once_for_both_reroutes():assert len(per_device) == 1, _run_install.probes-def test_the_shared_probe_still_reaches_strix_above_the_rocm_floor():- """The shared probe still reaches missing-kernel routing above the Strix floor."""- calls = _run_install(gfx_devices = ("gfx1103",), rocm_version = (7, 13))- assert f"{_AMD}/gfx110X-all/" in calls, calls--def test_the_mirror_override_is_honoured():calls = _run_install(gfx_devices = ("gfx1103",), env = {"UNSLOTH_AMD_ROCM_MIRROR": "https://mirror.test/whl"}diff --git a/tests/studio/install/test_pr4562_bugfixes.py b/tests/studio/install/test_pr4562_bugfixes.pyindex 4afe20718a2..4e3122a44c1 100644--- a/tests/studio/install/test_pr4562_bugfixes.py+++ b/tests/studio/install/test_pr4562_bugfixes.py@@ -79,23 +79,6 @@ def run_bash(class TestBinaryEnvCrossPlatform:"""binary_env returns correct library paths for all OSes (Bug 4)."""- def test_linux_includes_binary_parent_in_ld_library_path(- self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch- ):- install_dir = tmp_path / "llama.cpp"- bin_dir = install_dir / "build" / "bin"- bin_dir.mkdir(parents = True)- binary_path = bin_dir / "llama-server"- binary_path.write_bytes(b"fake")-- host = make_host(system = "Linux")- monkeypatch.setattr(MOD, "linux_runtime_dirs", lambda _bp: [])-- env = binary_env(binary_path, install_dir, host)- ld_dirs = env["LD_LIBRARY_PATH"].split(os.pathsep)- assert str(bin_dir) in ld_dirs, f"build/bin not in LD_LIBRARY_PATH: {ld_dirs}"- assert str(install_dir) in ld_dirs, f"install_dir not in LD_LIBRARY_PATH: {ld_dirs}"-def test_linux_binary_parent_comes_before_install_dir(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch):@@ -860,24 +843,6 @@ class TestSourceCodePatterns:assert "Sort-Object Name | Select-Object -Last 1" not in contentassert "Sort-Object { [version]($_.Name -replace '^v','') } -Descending" in content- def test_binary_env_linux_has_binary_parent(self):- """The Linux branch of binary_env should include binary_path.parent."""- content = MODULE_PATH.read_text(encoding = "utf-8")- in_func = False- in_linux = False- found = False- for line in content.splitlines():- if "def binary_env(" in line:- in_func = True- elif in_func and line and not line[0].isspace() and "def " in line:- break- if in_func and "host.is_linux" in line:- in_linux = True- if in_linux and "binary_path.parent" in line:- found = True- break- assert found, "binary_path.parent not found in Linux branch of binary_env"-# Bash fragment mirroring setup.sh's GPU backend decision chain.# _IS_MACOS_ARM64, NVCC_PATH, GPU_BACKEND are injected by tests.diff --git a/tests/studio/install/test_rdna1_multiarch_windows_route_11614.py b/tests/studio/install/test_rdna1_multiarch_windows_route_11614.pyindex f9d89e3eea6..0403ca1b0f6 100644--- a/tests/studio/install/test_rdna1_multiarch_windows_route_11614.py+++ b/tests/studio/install/test_rdna1_multiarch_windows_route_11614.py@@ -160,11 +160,6 @@ _RDNA1_NAMES = [class TestNameTables:- @pytest.mark.parametrize("name,expected", _RDNA1_NAMES)- def test_python_table_resolves_rdna1(self, name, expected):- assert stack_mod._gfx_arch_from_gpu_name(name) == expected- assert stack_mod._unsupported_gfx_arch_from_gpu_name(name) is None-@pytest.mark.parametrize("name", ["AMD Radeon RX 570", "AMD Radeon RX 580", "AMD Radeon RX 550"])diff --git a/tests/studio/install/test_rdna1_unsupported_message_8529.py b/tests/studio/install/test_rdna1_unsupported_message_8529.pyindex 11a9ecd354d..bfe03568888 100644--- a/tests/studio/install/test_rdna1_unsupported_message_8529.py+++ b/tests/studio/install/test_rdna1_unsupported_message_8529.py@@ -108,15 +108,6 @@ _RDNA1_NAMES = [("AMD Radeon Pro 5700 XT", "gfx1010"),]-# The generation that still has no wheels anywhere: Polaris 10/20/30 (#8458).-_POLARIS_FIXTURES = [- ("AMD Radeon RX 580", "gfx803"),- ("AMD Radeon RX 580 Series", "gfx803"),- ("AMD Radeon RX 570", "gfx803"),- ("AMD Radeon RX 480", "gfx803"),- ("AMD Radeon Pro WX 7100", "gfx803"),-]-# Cards the supported table owns, plus a non-AMD one._NOT_RDNA1_NAMES = ["AMD Radeon RX 9070 XT",@@ -145,11 +136,6 @@ class TestUnsupportedNameLookup:assert stack_mod._gfx_arch_from_gpu_name(name) == expectedassert stack_mod._unsupported_gfx_arch_from_gpu_name(name) is None- @pytest.mark.parametrize("name,expected", _POLARIS_FIXTURES)- def test_polaris_names_resolve_to_their_arch(self, name, expected):- assert stack_mod._unsupported_gfx_arch_from_gpu_name(name) == expected- assert stack_mod._gfx_arch_from_gpu_name(name) is None-@pytest.mark.parametrize("name", _NOT_RDNA1_NAMES)def test_supported_and_non_amd_names_are_not_claimed(self, name):assert stack_mod._unsupported_gfx_arch_from_gpu_name(name) is None@@ -1451,15 +1437,6 @@ class TestPolarisRow:def test_polaris_11_12_is_not_claimed(self, name):assert stack_mod._unsupported_gfx_arch_from_gpu_name(name) is None- @pytest.mark.parametrize("name,expected", _RDNA1_NAMES)- def test_polaris_patterns_do_not_swallow_rdna1(self, name, expected):- """The collision this row is one keystroke away from: "RX 570" is a prefix- of "RX 5700" and "RX 550" of "RX 5500". Re-assert every RDNA 1 name still- resolves to its own arch (in the Windows supported table since #11614) and is- not claimed by the Polaris row."""- assert stack_mod._gfx_arch_from_gpu_name(name) == expected- assert stack_mod._unsupported_gfx_arch_from_gpu_name(name) is None-@pytest.mark.parametrize("name,_expected", _RDNA1_NAMES)def test_the_polaris_pattern_is_correct_on_its_own(self, name, _expected):"""The test above passes for the wrong reason and cannot replace this one.diff --git a/tests/studio/install/test_rocm_support.py b/tests/studio/install/test_rocm_support.pyindex e36bb728417..8b3cf2db749 100644--- a/tests/studio/install/test_rocm_support.py+++ b/tests/studio/install/test_rocm_support.py@@ -610,16 +610,6 @@ class TestDetectRocmVersion:result = _detect_rocm_version()assert result is None- def test_version_with_epoch_prefix(self, tmp_path):- """Debian epoch prefix (2:6.2.0) -- version file has no epoch, so should parse."""- info_dir = tmp_path / ".info"- info_dir.mkdir()- (info_dir / "version").write_text("6.2.0\n")- with patch.dict(os.environ, {"ROCM_PATH": str(tmp_path)}):- with patch("shutil.which", return_value = None):- result = _detect_rocm_version()- assert result == (6, 2)-def test_multiple_version_sources_highest_wins(self, tmp_path):"""When ROCm version sources disagree, the highest valid version wins."""info_dir = tmp_path / ".info"diff --git a/tests/studio/install/test_woa_torch_index_persistence.py b/tests/studio/install/test_woa_torch_index_persistence.pyindex a0caf32b2b5..6f95d3c415e 100644--- a/tests/studio/install/test_woa_torch_index_persistence.py+++ b/tests/studio/install/test_woa_torch_index_persistence.py@@ -3036,11 +3036,6 @@ class TestARebasedOptionPathKeepsItsQuoting:argument[1:-1]).exists(), f"the rebased path does not resolve to the file it names: {got!r}"- def test_the_two_copies_stay_identical(self):- """setup.ps1 carries a parity copy; a fix applied to one is a bug in the other."""- install, setup = _ps_copies("Resolve-WoaOverrideLine")- assert install == setup-class TestALocalDirectoryRequirementIsRebasedToo:"""The line forms the fold moved and left behind. New-UnslothTorchOverridesFile writes to@@ -4682,10 +4677,6 @@ class TestARebasedFileReferenceIsAUri:)assert _ps_last(script)[1:-1] == 'pkg @ https://x.test/a.whl ; os_name == "nt"'- def test_the_two_copies_are_identical(self):- install, setup = _ps_copies("Resolve-WoaOverrideLine")- assert install == setup-class TestTheMergedOverrideFileDoesNotOutliveTheRun:"""It copies caller lines, which can carry credentials, into $StudioHome\\woa. It is nowdiff --git a/tests/studio/studiobench/scene/selftest/test_studiobench_follow_coverage_live.py b/tests/studio/studiobench/scene/selftest/test_studiobench_follow_coverage_live.pyindex fcec329cae4..378cdfa4ebf 100644--- a/tests/studio/studiobench/scene/selftest/test_studiobench_follow_coverage_live.py+++ b/tests/studio/studiobench/scene/selftest/test_studiobench_follow_coverage_live.py@@ -287,23 +287,6 @@ def test_a_run_the_user_started_reattaches_when_the_app_pins_for_it(page):)-def test_a_pin_inside_the_SAME_run_is_still_a_yank_and_not_a_reattachment(page):- """The other half has to survive. No new run started, so the app returning the viewport to the- bottom on its own is the behaviour the sampler exists to catch, not the user coming back."""- _start_at_bottom(page)- _settle(page)- page.evaluate("() => window.__sb.follow.suspend()")- _to_top(page)- page.evaluate("() => window.__sb.follow.resume()")- _settle(page, 400)- _to_bottom(page)- _settle(page)- got = _read(page)- assert got["reattachments"] == 0, got- assert got["yanked_back_samples"] > 0, got- assert got["yanked_after_scroll"] is True, got--def test_a_new_run_the_app_does_NOT_pin_for_leaves_the_sampler_detached(page):"""A run start is not a free pass. The re-attachment needs the viewport to actually BE at theend, so an app that leaves a scrolled-up user where they are is scored exactly as before."""diff --git a/tests/test_offload_tied_autodisable.py b/tests/test_offload_tied_autodisable.pyindex d0e394c7d05..ff0ec28d73d 100644--- a/tests/test_offload_tied_autodisable.py+++ b/tests/test_offload_tied_autodisable.py@@ -227,12 +227,6 @@ def test_hook_without_execution_device_keeps_offload():assert resolve(_dispatched_model(None), True) is True-def test_undispatched_model_keeps_offload():- # The single-GPU path must not lose the VRAM saving.- with _as_platform("posix"):- assert resolve(_untied_model(), True) is True--if __name__ == "__main__":for name, fn in sorted(globals().items()):if name.startswith("test_") and callable(fn):diff --git a/unsloth_cli/tests/test_studio_update_uv_cache.py b/unsloth_cli/tests/test_studio_update_uv_cache.pyindex d16cf8dde50..78899d339dc 100644--- a/unsloth_cli/tests/test_studio_update_uv_cache.py+++ b/unsloth_cli/tests/test_studio_update_uv_cache.py@@ -481,17 +481,6 @@ def test_the_recorded_install_cache_beats_both_guesses(monkeypatch, tmp_path, caassert seen["env"]["UV_CACHE_DIR"] == str(default_cache), seen["env"].get("UV_CACHE_DIR")-def test_a_recorded_studio_cache_survives_the_user_warming_their_own(monkeypatch, tmp_path, caches):- """The mirror: a studio install, and the user has since warmed uv's own cache."""- studio_cache, default_cache = caches- _fill(studio_cache)- _fill(default_cache)- _record(tmp_path / "StudioHome", studio_cache)- seen = _run_posix(monkeypatch, tmp_path)-- assert seen["env"]["UV_CACHE_DIR"] == str(studio_cache), seen["env"].get("UV_CACHE_DIR")--def test_an_emptied_recorded_cache_does_not_outrank_a_warm_one(monkeypatch, tmp_path, caches):"""A marker pointing at an emptied cache is stale, not authoritative."""studio_cache, default_cache = caches@@ -502,15 +491,6 @@ def test_an_emptied_recorded_cache_does_not_outrank_a_warm_one(monkeypatch, tmp_assert seen["env"]["UV_CACHE_DIR"] == str(default_cache), seen["env"].get("UV_CACHE_DIR")-def test_installs_older_than_the_marker_still_work(monkeypatch, tmp_path, caches):- """The normal state for everyone installed before this change."""- studio_cache, _default = caches- _fill(studio_cache)- seen = _run_posix(monkeypatch, tmp_path)-- assert seen["env"]["UV_CACHE_DIR"] == str(studio_cache), seen["env"].get("UV_CACHE_DIR")--def test_a_reinstall_into_a_custom_cache_is_not_shadowed_by_the_old_marker(monkeypatch, tmp_path, caches):