ComfyUI/tests-unit
RyanOnTheInside abfea891ef Fix conditioning mask normalization for arbitrary spatial dimensions.
May also resolve #9784 — the mask normalization fixes a class of dimensionality mismatches that can cause the `y, x = torch.where(mask)` crash in `get_mask_aabb`, though the root cause in that report is unconfirmed.

## Summary

`resolve_areas_and_cond_masks_multidim` assumes 2D spatial masks. This breaks for 1D audio models (StableAudio1, ACEAudio15) because upstream code (`ConditioningSetMask`, `set_mask_for_conditioning`) unconditionally unsqueezes masks with `ndim < 3`, corrupting valid `[B, L]` masks into `[1, B, L]` before they reach the sampler.

This PR:
- Normalizes masks to `[batch, *spatial_dims]` using `dims` as the source of truth
- Adds a 1D resize path via `F.interpolate(mode='linear')`
- Guards `set_area_to_bounds` with `len(dims) == 2` to prevent crashes on non-2D masks (the existing `get_mask_aabb` and `H, W, Y, X` unpacking are 2D-only)

The root cause is the hardcoded `if len(mask.shape) < 3` in `nodes.py:242` and `hooks.py:725`. Fixing it there would require threading latent dimensionality into the conditioning nodes — a much larger change. Normalizing in `resolve_areas_and_cond_masks_multidim` where `dims` is already available is the minimal fix.

Fully backwards compatible for existing 2D image and 3D video workflows.

## Test plan

- [x] 26 unit tests covering 1D/2D/3D mask normalization, resize, and `set_area_to_bounds` guard (`tests-unit/comfy_test/samplers_test.py`)
- [x] 2D image regression with hook masking: [lorahookmasking.json](https://github.com/Kosinkadink/ComfyUI/blob/workflows/lorahookmasking.json)
- [x] 2D image with `set_area_to_bounds` ("mask bounds" mode) — no crash, correct area computation
- [x] 1D audio with conditioning mask: [acestep-1.5-prompt-lora-blending.json](https://github.com/ryanontheinside/ComfyUI_RyanOnTheInside/blob/main/examples/ace1.5/acestep-1.5-prompt-lora-blending.json) (requires custom nodes that patch this function pending upstream)
2026-02-15 09:45:14 -05:00
..
app_test feat(security): add System User protection with __ prefix (#10966) 2025-11-28 21:28:42 -05:00
assets_test Assets Part 2 - add more endpoints (#12125) 2026-01-31 02:22:05 -05:00
comfy_api_test Add get_duration method to Comfy VIDEO type (#8122) 2025-05-15 00:11:41 -04:00
comfy_extras_test [V3] converted nodes_images.py to V3 schema (#11206) 2025-12-26 19:39:02 -08:00
comfy_quant Properly save mixed ops. (#11772) 2026-01-10 02:03:57 -05:00
comfy_test Fix conditioning mask normalization for arbitrary spatial dimensions. 2026-02-15 09:45:14 -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
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 Assets Part 2 - add more endpoints (#12125) 2026-01-31 02:22:05 -05: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/