ComfyUI/tests-unit
haoshu.gu 59c565adf3 Fix duplicate custom node import when cross-referenced
When one custom node imports another custom node (e.g., via 'import custom_nodes.other_node'),
the ComfyUI custom node loader would previously load the imported node twice:
1. First time: via the explicit import statement (module name: custom_nodes.other_node)
2. Second time: via the automatic custom node scanner (module name: custom_nodes/other_node)

This caused issues including:
- Module initialization code being executed twice
- Route handlers being registered multiple times
- Potential state inconsistencies and data loss

This fix adds a check before loading a custom node to detect if it's already loaded
in sys.modules under either the standard import name or the path-based name.
If already loaded, it reuses the existing module instead of re-executing it.

Benefits:
- Prevents duplicate initialization of custom nodes
- Allows custom nodes to safely import other custom nodes
- Improves performance by avoiding redundant module loading
- Maintains backward compatibility with existing custom nodes

Also includes linting fix: use lazy % formatting in logging functions.
2025-12-24 05:51:37 +08:00
..
app_test feat(security): add System User protection with __ prefix (#10966) 2025-11-28 21:28:42 -05:00
comfy_api_nodes_test More API Nodes (#7956) 2025-05-06 04:23:00 -04:00
comfy_api_test Add get_duration method to Comfy VIDEO type (#8122) 2025-05-15 00:11:41 -04:00
comfy_extras_test [feat] Add GetImageSize node (#8386) 2025-06-02 21:57:50 -04:00
comfy_quant Make old scaled fp8 format use the new mixed quant ops system. (#11000) 2025-12-05 14:35:42 -05:00
comfy_test Allow changing folder_paths.base_path via command line argument. (#6600) 2025-01-29 08:06:28 -05:00
execution_test feat(preview): add per-queue live preview method override (#11261) 2025-12-15 15:57:39 -08:00
folder_paths_test feat(security): add System User protection with __ prefix (#10966) 2025-11-28 21:28:42 -05:00
nodes_test Fix duplicate custom node import when cross-referenced 2025-12-24 05:51:37 +08:00
prompt_server_test feat(security): add System User protection with __ prefix (#10966) 2025-11-28 21:28:42 -05:00
server/utils Remove unused GET /files API endpoint (#6714) 2025-02-05 18:48:36 -05:00
server_test dont cache new locale entry points (#10101) 2025-09-29 12:16:02 -07:00
utils Normalize extra_model_config.yaml paths to prevent duplicates. (#6885) 2025-02-20 07:09:45 -05:00
feature_flags_test.py Support for async node functions (#8830) 2025-07-10 14:46:19 -04:00
README.md Minor: update tests-unit README.md (#4896) 2024-09-12 04:53:08 -04:00
requirements.txt Support for async node functions (#8830) 2025-07-10 14:46:19 -04:00
websocket_feature_flags_test.py Support for async node functions (#8830) 2025-07-10 14:46:19 -04:00

Pytest Unit Tests

Install test dependencies

pip install -r tests-unit/requirements.txt

Run tests

pytest tests-unit/