Skip to content

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.

Tests: let the install damage and reinstall hint tests run on Windows (#17022)

Daniel Hanee66d292be59
diff --git a/tests/studio/install/test_install_manifest_damage.py b/tests/studio/install/test_install_manifest_damage.py
index 73bbff40174..660104b822f 100644
--- a/tests/studio/install/test_install_manifest_damage.py
+++ b/tests/studio/install/test_install_manifest_damage.py
@@ -198,6 +198,7 @@ def test_an_unreadable_file_is_not_damage(site_packages):
os.chmod(target, 0o644)
[email protected](sys.platform == "win32", reason = "a Windows file name cannot hold a line break")
def test_a_quoted_line_break_in_a_recorded_name_is_not_damage(site_packages):
"""RECORD is CSV: a quoted field may hold a newline that splitlines breaks."""
dist_info = _dist(site_packages)
@@ -316,7 +317,9 @@ def test_a_package_directory_replaced_by_a_file_is_damage(site_packages):
shutil.rmtree(site_packages / PKG)
(site_packages / PKG).write_text("quarantined", encoding = "utf-8")
- assert install_manifest.damaged_payload_files(PKG) == [f"{PKG}/__init__.py is not reachable"]
+ # Windows reports a file in the middle of a path as a missing path, not ENOTDIR; damage either way.
+ reason = "is missing" if sys.platform == "win32" else "is not reachable"
+ assert install_manifest.damaged_payload_files(PKG) == [f"{PKG}/__init__.py {reason}"]
def test_the_companion_distribution_is_scanned_too(site_packages):
diff --git a/unsloth_cli/tests/test_studio_update_verify.py b/unsloth_cli/tests/test_studio_update_verify.py
index 0735d180acc..5c92ba673c2 100644
--- a/unsloth_cli/tests/test_studio_update_verify.py
+++ b/unsloth_cli/tests/test_studio_update_verify.py
@@ -458,15 +458,20 @@ def test_a_tauri_update_is_verified_too(monkeypatch):
@pytest.mark.parametrize(
"system, expected",
[
- ("Linux", "| UNSLOTH_STUDIO_HOME=/srv/studios/a sh"),
- ("Windows", "$env:UNSLOTH_STUDIO_HOME = '/srv/studios/a'; irm"),
+ ("Linux", "| UNSLOTH_STUDIO_HOME={quoted} sh"),
+ ("Windows", "$env:UNSLOTH_STUDIO_HOME = '{root}'; irm"),
],
)
def test_a_custom_root_is_carried_into_the_reinstall_command(monkeypatch, capsys, system, expected):
import platform as _platform
+ import shlex
+
import typer
studio = _studio()
+ # The root as this host spells it: a Windows runner prints `\srv\studios\a` for either target shell.
+ root = str(Path("/srv/studios/a"))
+ expected = expected.format(root = root, quoted = shlex.quote(root))
monkeypatch.setattr(studio._studio_deps, "running_outside_managed_venv", lambda *a: False)
monkeypatch.setattr(
studio._studio_deps, "damaged_installed_files", lambda *a, **k: ["x: y is missing"]
@@ -493,7 +498,10 @@ def test_a_root_with_spaces_is_quoted(monkeypatch, capsys):
monkeypatch.setattr(_platform, "system", lambda: "Linux")
with pytest.raises(typer.Exit):
studio._fail_if_install_damaged()
- assert "UNSLOTH_STUDIO_HOME='/srv/my studios/a' sh" in capsys.readouterr().err
+ import shlex
+
+ root = shlex.quote(str(Path("/srv/my studios/a"))) # as this host prints it
+ assert f"UNSLOTH_STUDIO_HOME={root} sh" in capsys.readouterr().err
@pytest.mark.parametrize(
@@ -592,14 +600,19 @@ def test_the_message_covers_packages_the_installer_will_not_repair(monkeypatch,
@pytest.mark.parametrize(
"system, exe, expected",
[
- ("Linux", "/srv/my studios/a/bin/python", "'/srv/my studios/a/bin/python' -m pip"),
- ("Windows", r"C:\my studios\a\python.exe", "& 'C:\\my studios\\a\\python.exe' -m pip"),
+ ("Linux", "/srv/my studios/a/bin/python", "{quoted} -m pip"),
+ ("Windows", r"C:\my studios\a\python.exe", "& '{path}' -m pip"),
],
)
def test_the_repair_command_quotes_the_interpreter(monkeypatch, capsys, system, exe, expected):
import platform as _platform
+ import shlex
+
import typer
+ # The interpreter as this host prints it (a POSIX path gets backslashes on a Windows runner).
+ expected = expected.format(path = str(Path(exe)), quoted = shlex.quote(str(Path(exe))))
+
studio = _studio()
monkeypatch.setattr(studio._studio_deps, "running_outside_managed_venv", lambda *a: False)
monkeypatch.setattr(