Critical:
- _load_module(): wrap exec_module() in try/except, pop from sys.modules
on failure so broken modules aren't cached
- get_comfyui_path(): add _is_comfyui_directory() check to third (CWD walk)
strategy so a non-ComfyUI directory named "ComfyUI" isn't accepted
- get_node_class_mappings(): return cached sys.modules["nodes"] if already
loaded to avoid re-executing nodes.py and losing init_extra_nodes() state
Suggestions:
- import_custom_nodes(): wrap sys.path filtering in try/finally so path is
always restored even if _load_module("server") raises mid-execution
- render.py: auto-discover helpers from generated_helpers.__all__ instead of
a manually maintained list
- pyproject.toml: remove duplicate ruff dev dependency (kept standard
[project.optional-dependencies] form)
Nitpicks:
- Remove dead imports (types, StringIO) from test_import_path_resolution.py
- Trim trailing blank lines in pyproject.toml
- Tone down _load_module docstring: "eliminates ALL" -> "significantly reduces"
Tests (7 new cases):
- TestLoadModuleFailureCleanup: broken module removed on exec failure, retry
starts fresh
- TestLoadModuleTemp: temp modules purged from sys.modules (success + failure)
- TestRepeatedNodeLoad: repeated _load_module("nodes") returns cached copy
- TestGetComfyuiPathThirdStrategy: fake "ComfyUI" dir rejected
- TestImportCustomNodesSysPathRestoration: sys.path restored after crash
Tests
This directory contains two test paths:
- unit tests for exporter behavior
- runtime validation for committed workflow fixtures
Use the lightweight path for routine contributor validation, and use the runtime path when you need end-to-end confidence against a real ComfyUI checkout.
Prerequisites
- Run commands from the repo root.
- Use
uvfor all project commands. - Install the repo environment first:
uv sync
- Runtime validation also needs a working ComfyUI checkout.
Set
COMFYUI_PATHto that checkout, or run the tests from a location where a parent directory containsComfyUI. - Runtime-tier tests do not download missing models automatically.
If a required model is missing, the fixture fails with
model provisioning failure. Use--print-download-planto print the manual download commands.
Runtime Model Requirements
The current runtime-capable fixtures require these model files in the target ComfyUI checkout:
text-to-image:models/checkpoints/v1-5-pruned-emaonly-fp16.safetensorsupscale-model-loader:models/upscale_models/RealESRGAN_x4plus.safetensors
Unit Tests
Run the exporter-focused unit test module:
uv run python -m unittest tests.test_upscale_model_loader_export
Run the runtime-harness unit test module:
uv run python -m unittest tests.test_runtime_validation_harness
Run all unittest-discoverable tests under tests:
uv run python -m unittest discover -s tests
Runtime Tests
The runtime harness lives at tests/runtime/run_runtime_validation.py.
Fast Tier
Fast tier validates export behavior against committed fixtures without requiring a full ComfyUI runtime for every fixture. This is the recommended default validation lane for routine changes.
Run all fast-tier compatible fixtures:
uv run python tests/runtime/run_runtime_validation.py --tier fast --fixture all
Run one fixture:
uv run python tests/runtime/run_runtime_validation.py --tier fast --fixture unsafe-kwargs
Runtime Tier
Runtime tier exports inside a real ComfyUI checkout and executes generated Python for runtime-capable fixtures. This is the heavier validation lane for changes that need end-to-end runtime confidence.
Run all runtime-capable fixtures:
uv run python tests/runtime/run_runtime_validation.py --tier runtime --fixture all
Run one runtime-capable fixture:
uv run python tests/runtime/run_runtime_validation.py --tier runtime --fixture text-to-image
Print download commands for missing models instead of failing immediately:
uv run python tests/runtime/run_runtime_validation.py --tier runtime --fixture all --print-download-plan
Runtime Fixture Names
Current committed fixtures:
upscale-model-loadertext-to-imageunsafe-kwargssubgraph-identifiersreused-node-class-branchessecondary-output-selection
Notes:
--tier runtimeonly runs fixtures marked runtime-capable.--tier fastonly runs fixtures with local test mappings.reused-node-class-branchesprotects repeated node-class usage and branch wiring in the fast tier.secondary-output-selectionprotects non-zero output index wiring in the fast tier.
Troubleshooting
No module named ...: runuv syncin this repo, and for runtime-tier failures also make sure the target ComfyUI checkout has its own dependencies installed.Could not find a valid ComfyUI checkout for runtime validation.: setCOMFYUI_PATHto your ComfyUI checkout, or run the tests from a directory layout where a parent folder containsComfyUI.Missing models for ...: runtime-tier tests do not fetch models for you. Rerun with--print-download-planto print the expectedcurlcommands and target model directories, then install the files manually.No selected fixtures are runtime-capable for this tier.: choose a runtime-capable fixture such astext-to-imageorupscale-model-loader.- Generated script execution fails because files or models are missing:
confirm the required models exist under the target ComfyUI checkout and that any staged inputs can be copied into its
input/directory.