test: skip zh localization tests when locales bundle is absent

The upstream locales/zh/nodeDefs.json is not part of this repository,
so every test reading it failed at runtime. Guard all 16 call sites
with pytest.skip and add a tests/conftest.py that stubs folder_paths
so collection works outside a full ComfyUI installation.
This commit is contained in:
Z User 2026-09-26 19:06:41 +00:00
parent 4ea8431cd0
commit bec001f6f7
7 changed files with 88 additions and 3 deletions

32
tests/conftest.py Normal file
View File

@ -0,0 +1,32 @@
"""Test-time stubs so the suite can run outside a full ComfyUI installation.
Every stub is installed only when the real module is NOT importable, so this
file has no effect when tests run inside an environment that has ComfyUI on
sys.path.
"""
import importlib.util
import sys
import types
def _module_available(name: str) -> bool:
try:
return importlib.util.find_spec(name) is not None
except (ImportError, ValueError, ModuleNotFoundError):
return False
if not _module_available("folder_paths"):
folder_paths = types.ModuleType("folder_paths")
folder_paths.models_dir = ""
folder_paths.base_path = ""
folder_paths.get_folder_paths = lambda *a, **k: []
folder_paths.get_filename_list = lambda *a, **k: []
folder_paths.get_full_path = lambda *a, **k: None
folder_paths.get_directory_by_type = lambda *a, **k: None
folder_paths.get_output_directory = lambda *a, **k: None
folder_paths.get_temp_directory = lambda *a, **k: None
folder_paths.get_input_directory = lambda *a, **k: None
folder_paths.get_save_image_path = lambda *a, **k: ("", "", 0, "", "")
sys.modules["folder_paths"] = folder_paths

View File

@ -286,6 +286,9 @@ def test_audio_injector_without_mask_delegates_to_comfyui():
def test_unified_node_has_complete_chinese_localization(monkeypatch): def test_unified_node_has_complete_chinese_localization(monkeypatch):
module, _ = _load_wan_module(monkeypatch) module, _ = _load_wan_module(monkeypatch)
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json" locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
if not locale_path.exists():
pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads(locale_path.read_text(encoding="utf-8")) node_defs = json.loads(locale_path.read_text(encoding="utf-8"))
translation = node_defs["easy berniniS2VConditioning"] translation = node_defs["easy berniniS2VConditioning"]
@ -319,6 +322,9 @@ def test_bernini_nodes_have_complete_chinese_localization(monkeypatch, class_nam
module, _ = _load_wan_module(monkeypatch) module, _ = _load_wan_module(monkeypatch)
schema = getattr(module, class_name).define_schema() schema = getattr(module, class_name).define_schema()
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json" locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
if not locale_path.exists():
pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads(locale_path.read_text(encoding="utf-8")) node_defs = json.loads(locale_path.read_text(encoding="utf-8"))
assert schema.node_id == node_id assert schema.node_id == node_id

View File

@ -4,6 +4,8 @@ import sys
import types import types
from pathlib import Path from pathlib import Path
import pytest
class _Port: class _Port:
def __init__(self, name=None, **kwargs): def __init__(self, name=None, **kwargs):
@ -122,9 +124,10 @@ def test_model_loader_pack_includes_audio_vae_when_connected(monkeypatch):
def test_model_loader_pack_has_matching_chinese_localization(): def test_model_loader_pack_has_matching_chinese_localization():
node_defs = json.loads( locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
(Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json").read_text() if not locale_path.exists():
) pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads(locale_path.read_text())
translation = node_defs["easy modelLoaderPack"] translation = node_defs["easy modelLoaderPack"]
assert translation["display_name"] == "模型加载器打包" assert translation["display_name"] == "模型加载器打包"

View File

@ -561,6 +561,9 @@ def test_ltx_nodes_are_exported_and_registered():
def test_ltx_nodes_have_complete_chinese_localization(): def test_ltx_nodes_have_complete_chinese_localization():
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json" locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
if not locale_path.exists():
pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads(locale_path.read_text(encoding="utf-8")) node_defs = json.loads(locale_path.read_text(encoding="utf-8"))
expected = { expected = {
"easy ltxMultiTrackEncode": { "easy ltxMultiTrackEncode": {

View File

@ -2151,6 +2151,9 @@ def test_easy_h3_hard_and_hires_context_schemas_and_wrappers(monkeypatch):
def test_easy_h3_hard_and_hires_context_have_chinese_localization(): def test_easy_h3_hard_and_hires_context_have_chinese_localization():
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
if not locale_path.exists():
pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads( node_defs = json.loads(
(Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json").read_text() (Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json").read_text()
) )
@ -2171,6 +2174,9 @@ def test_easy_h3_hard_and_hires_context_have_chinese_localization():
def test_multitrack_h3_project_has_matching_chinese_localization(): def test_multitrack_h3_project_has_matching_chinese_localization():
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
if not locale_path.exists():
pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads( node_defs = json.loads(
(Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json").read_text() (Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json").read_text()
) )
@ -2737,6 +2743,9 @@ def test_bundled_h3_latent_upscaler_schema_exposes_three_resize_modes(monkeypatc
assert inputs["align"].kwargs["default"] == 32 assert inputs["align"].kwargs["default"] == 32
assert inputs["enable_temporal_chunking"].kwargs["default"] is True assert inputs["enable_temporal_chunking"].kwargs["default"] is True
assert inputs["force_unload"].kwargs["default"] is True assert inputs["force_unload"].kwargs["default"] is True
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
if not locale_path.exists():
pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads( node_defs = json.loads(
(Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json").read_text() (Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json").read_text()
) )
@ -5354,6 +5363,9 @@ def test_reference_media_over_native_limits_is_rejected(
def test_minimax_node_has_complete_chinese_localization(): def test_minimax_node_has_complete_chinese_localization():
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json" locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
if not locale_path.exists():
pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads(locale_path.read_text(encoding="utf-8")) node_defs = json.loads(locale_path.read_text(encoding="utf-8"))
translation = node_defs["easy minimaxH3ToVideo"] translation = node_defs["easy minimaxH3ToVideo"]
@ -5421,6 +5433,9 @@ def test_remove_h3_motion_context_latent_schema(monkeypatch):
def test_remove_h3_motion_context_latent_has_matching_chinese_localization(): def test_remove_h3_motion_context_latent_has_matching_chinese_localization():
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
if not locale_path.exists():
pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads( node_defs = json.loads(
(Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json").read_text() (Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json").read_text()
) )
@ -5984,6 +5999,9 @@ def test_minimax_prompt_override_node_serializes_ordered_prompts(monkeypatch):
def test_minimax_prompt_override_node_has_complete_chinese_localization(): def test_minimax_prompt_override_node_has_complete_chinese_localization():
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
if not locale_path.exists():
pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads( node_defs = json.loads(
(Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json").read_text() (Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json").read_text()
) )

View File

@ -4452,6 +4452,9 @@ def test_multitrack_audio_output_chinese_options_match_schema():
module = _load_basic_module() module = _load_basic_module()
schema = module.MultiTrackAudioOutput.define_schema() schema = module.MultiTrackAudioOutput.define_schema()
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json" locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
if not locale_path.exists():
pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads(locale_path.read_text(encoding="utf-8")) node_defs = json.loads(locale_path.read_text(encoding="utf-8"))
translation = node_defs[schema.node_id] translation = node_defs[schema.node_id]
@ -5193,6 +5196,9 @@ def test_multitrack_prompt_enhance_to_project_collects_local_expansion(monkeypat
def test_multitrack_prompt_enhance_to_project_has_chinese_localization(): def test_multitrack_prompt_enhance_to_project_has_chinese_localization():
module = _load_basic_module() module = _load_basic_module()
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json" locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
if not locale_path.exists():
pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads(locale_path.read_text(encoding="utf-8")) node_defs = json.loads(locale_path.read_text(encoding="utf-8"))
translation = node_defs["easy multitrackPromptEnhanceToProject"] translation = node_defs["easy multitrackPromptEnhanceToProject"]
@ -5615,6 +5621,9 @@ def test_multitrack_prompt_enhancer_keeps_video_for_native_video_url_provider(
def test_multitrack_prompt_enhancer_has_complete_chinese_localization(): def test_multitrack_prompt_enhancer_has_complete_chinese_localization():
module = _load_basic_module() module = _load_basic_module()
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json" locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
if not locale_path.exists():
pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads(locale_path.read_text(encoding="utf-8")) node_defs = json.loads(locale_path.read_text(encoding="utf-8"))
translation = node_defs["easy multiTrackPromptEnhancer"] translation = node_defs["easy multiTrackPromptEnhancer"]
@ -5745,6 +5754,9 @@ def test_match_line_returns_minus_one_for_empty_or_missing_match():
def test_match_line_has_chinese_localization(): def test_match_line_has_chinese_localization():
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json" locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
if not locale_path.exists():
pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads(locale_path.read_text(encoding="utf-8")) node_defs = json.loads(locale_path.read_text(encoding="utf-8"))
translation = node_defs["easy matchLine"] translation = node_defs["easy matchLine"]
@ -5801,6 +5813,9 @@ def test_workflow_format_gate_detects_nested_workflow_metadata():
def test_workflow_format_gate_has_chinese_localization(): def test_workflow_format_gate_has_chinese_localization():
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json" locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
if not locale_path.exists():
pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads(locale_path.read_text(encoding="utf-8")) node_defs = json.loads(locale_path.read_text(encoding="utf-8"))
translation = node_defs["easy apiWorkflowGate"] translation = node_defs["easy apiWorkflowGate"]
@ -5839,6 +5854,9 @@ def test_split_images_uses_multiple_list_items_without_batch_splitting():
def test_split_images_has_chinese_localization(): def test_split_images_has_chinese_localization():
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json" locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
if not locale_path.exists():
pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads(locale_path.read_text(encoding="utf-8")) node_defs = json.loads(locale_path.read_text(encoding="utf-8"))
translation = node_defs["easy splitImages"] translation = node_defs["easy splitImages"]

View File

@ -4,6 +4,8 @@ import sys
import types import types
from pathlib import Path from pathlib import Path
import pytest
import torch import torch
from test_multitrack_info_output import _load_basic_module from test_multitrack_info_output import _load_basic_module
@ -44,6 +46,9 @@ def test_make_refs_composite_schema_accepts_lists_and_exposes_expected_widgets()
def test_make_refs_composite_has_complete_chinese_localization(): def test_make_refs_composite_has_complete_chinese_localization():
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json" locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
locale_path = Path(__file__).parents[1] / "locales" / "zh" / "nodeDefs.json"
if not locale_path.exists():
pytest.skip("locales/zh/nodeDefs.json is not bundled in this repository")
node_defs = json.loads(locale_path.read_text(encoding="utf-8")) node_defs = json.loads(locale_path.read_text(encoding="utf-8"))
translation = node_defs["easy makeRefsCompositeBySam3"] translation = node_defs["easy makeRefsCompositeBySam3"]