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: bring three new tests in line with the port and encoding guards (#15745)

Daniel Hanef726b9ca427
diff --git a/tests/test_gc_skip_auto_dist_cells.py b/tests/test_gc_skip_auto_dist_cells.py
index c4ddbd811e3..89fbfe50d25 100644
--- a/tests/test_gc_skip_auto_dist_cells.py
+++ b/tests/test_gc_skip_auto_dist_cells.py
@@ -7,7 +7,6 @@ every rank takes it at the same forward, and that DDP training is unchanged by t
import datetime
import multiprocessing
import os
-import socket
import sys
import types
@@ -19,9 +18,8 @@ GIB = 1 << 30
def _free_port():
- with socket.socket() as s:
- s.bind(("127.0.0.1", 0))
- return s.getsockname()[1]
+ from tests._rendezvous_port import free_port
+ return free_port()
def _load(
diff --git a/tests/test_gc_skip_auto_dist_gloo.py b/tests/test_gc_skip_auto_dist_gloo.py
index 17bf1e5c624..21b7c343b7c 100644
--- a/tests/test_gc_skip_auto_dist_gloo.py
+++ b/tests/test_gc_skip_auto_dist_gloo.py
@@ -5,7 +5,6 @@
import multiprocessing
import os
-import socket
import sys
import pytest
@@ -16,9 +15,8 @@ GIB = 1 << 30
def _free_port():
- with socket.socket() as s:
- s.bind(("127.0.0.1", 0))
- return s.getsockname()[1]
+ from tests._rendezvous_port import free_port
+ return free_port()
def _worker(rank, world, port, usable, queue):
diff --git a/tests/test_mamba_fused_lora_adapters.py b/tests/test_mamba_fused_lora_adapters.py
index c4b86645566..504a6459ef5 100644
--- a/tests/test_mamba_fused_lora_adapters.py
+++ b/tests/test_mamba_fused_lora_adapters.py
@@ -461,7 +461,7 @@ def test_disabled_adapter_keeps_raw_weights(monkeypatch, arch):
def test_post_patch_model_installs_the_routing():
# FastModel.from_pretrained and get_peft_model both end in FastBaseModel.post_patch_model.
- tree = ast.parse((_ROOT / "unsloth" / "models" / "vision.py").read_text())
+ tree = ast.parse((_ROOT / "unsloth" / "models" / "vision.py").read_text(encoding = "utf-8"))
post = next(
node
for node in ast.walk(tree)
diff --git a/tests/test_refresh_moved_layer_devices.py b/tests/test_refresh_moved_layer_devices.py
index 8dadee41f13..b17f33f9deb 100644
--- a/tests/test_refresh_moved_layer_devices.py
+++ b/tests/test_refresh_moved_layer_devices.py
@@ -78,7 +78,7 @@ def test_block_swap_and_other_device_types_are_left_alone():
@pytest.mark.parametrize("path", DECODE_LOOPS)
def test_every_decode_loop_refreshes_before_reading_layer_devices(path):
- source = (REPOSITORY_ROOT / path).read_text()
+ source = (REPOSITORY_ROOT / path).read_text(encoding = "utf-8")
refresh = source.find("refresh_moved_layer_devices(self.model.layers, block_swap)")
read = source.find("per_layer_device(decoder_layer)")
assert 0 <= refresh < read, path