mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-10-12 12:32:11 -03:00
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:
@@ -36,6 +36,7 @@ from py.utils.example_images_processor import (
|
||||
)
|
||||
from py.utils.metadata_manager import MetadataManager
|
||||
from tests.conftest import MockCache, MockModelService, MockScanner
|
||||
import os
|
||||
|
||||
|
||||
class StubLockProvider:
|
||||
@@ -655,7 +656,8 @@ async def test_filename_template_use_case_reverts_to_recorded_original_when_temp
|
||||
lifecycle = StubLifecycleService()
|
||||
|
||||
async def metadata_loader(metadata_path: str) -> Dict[str, Any]:
|
||||
if metadata_path == "/library/alpha-renamed.metadata.json":
|
||||
# Compare the basename: the sidecar path is platform-spelled.
|
||||
if os.path.basename(metadata_path) == "alpha-renamed.metadata.json":
|
||||
return {"original_file_name": "alpha-original"}
|
||||
return {}
|
||||
|
||||
@@ -713,8 +715,10 @@ async def test_filename_template_use_case_skips_revert_matching_current_name() -
|
||||
async def test_filename_template_use_case_counts_conflicts_as_failures() -> None:
|
||||
_set_filename_template("{model_name}")
|
||||
scanner = MockScanner(cache=MockCache([
|
||||
_filename_template_model("/library/alpha.safetensors", "Alpha"),
|
||||
_filename_template_model("/library/beta.safetensors", "Beta"),
|
||||
# The names differ beyond case: on Windows a case-only difference counts
|
||||
# as "already named that" (os.path.normcase) and would be skipped.
|
||||
_filename_template_model("/library/alpha.safetensors", "Alpha Two"),
|
||||
_filename_template_model("/library/beta.safetensors", "Beta Two"),
|
||||
]))
|
||||
lifecycle = StubLifecycleService()
|
||||
lifecycle.error = ValueError("A file with this name already exists")
|
||||
|
||||
Reference in New Issue
Block a user