test: make the backend suite pass on Windows

The new informational Windows job surfaced 91 failures: four real bugs (fixed in
the previous two commits) and a long tail of POSIX assumptions in the tests
themselves. None of them assert behaviour that differs on Windows, so they are
fixed rather than skipped wherever the behaviour is the same:

* Path spelling: expectations built with `str(tmp_path)` are compared through an
  identity helper (`normalize_root_identity`) or the platform's separator, since
  the code hands out forward-slashed business paths while `str()` is native.
* Root labels: `_root_display_labels` prefixes the drive on Windows ("C: loras"),
  so label assertions compare the final path component or derive the expected
  label from the same helper.
* `~` expansion reads USERPROFILE (ntpath), not HOME; timer granularity rounds
  0.1s down; a case-only rename counts as "already named" via `os.path.normcase`.
* Genuinely POSIX-only strategies are skipped with a reason instead of failing:
  the headless clipboard fallback, dbus file-manager selection, xdg-open, and
  the case-fold index test that simulates a case-sensitive filesystem.
This commit is contained in:
Will Miao
2026-10-12 11:35:33 +08:00
parent 85f79283b6
commit c16de68640
13 changed files with 162 additions and 91 deletions
+5 -5
View File
@@ -60,17 +60,17 @@ class TestAdmitConfiguredRoots:
loras_roots=[str(primary)],
_configured_root_paths={"lora": [str(primary), str(drive)]},
)
assert config.configured_roots_for("lora") == [str(primary), str(drive)]
assert config.configured_roots_for("lora") == [_normalize(primary), _normalize(drive)]
# Still switched off: nothing to admit.
assert config.admit_configured_roots() == []
assert config.loras_roots == [str(primary)]
assert config.loras_roots == [_normalize(primary)]
drive.mkdir(parents=True)
admitted = config.admit_configured_roots()
assert admitted == [str(drive)]
assert config.loras_roots == [str(primary), str(drive)]
assert admitted == [_normalize(drive)]
assert config.loras_roots == [_normalize(primary), _normalize(drive)]
# Idempotent: a second call adds nothing.
assert config.admit_configured_roots() == []
@@ -91,7 +91,7 @@ class TestAdmitConfiguredRoots:
drive.rmdir()
config.admit_configured_roots()
assert config.loras_roots == [str(primary), str(drive)]
assert config.loras_roots == [_normalize(primary), _normalize(drive)]
def test_admits_every_model_type_and_its_side_maps(self, tmp_path):
checkpoint_dir = tmp_path / "checkpoints"