Skip to content

Commit 60cb0d9

Browse files
author
Cipher
committed
fix: ensure proper cleanup of SUPPORTED_READERS in test
The finally block now correctly handles both cases: - If 'itkreader' existed originally: restore the original reader - If 'itkreader' didn't exist originally: remove the test entry This prevents leaving the patched reader in place when the key was absent originally, ensuring clean test isolation. Signed-off-by: Cipher <cipher@openclaw.ai>
1 parent 5192676 commit 60cb0d9

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

tests/transforms/test_load_image.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,12 @@ def failing_reader(*args, **kwargs):
549549
f"Expected 'not installed' in debug logs, got: {cm.output}",
550550
)
551551
finally:
552-
# Restore original reader
552+
# Restore or remove the reader depending on whether it existed originally
553553
if original_itk is not None:
554554
SUPPORTED_READERS["itkreader"] = original_itk
555+
else:
556+
# Remove the entry if it didn't exist originally
557+
SUPPORTED_READERS.pop("itkreader", None)
555558

556559
def test_explicit_reader_available_succeeds(self):
557560
"""When the user explicitly names a reader whose package IS installed, no exception is raised."""

0 commit comments

Comments
 (0)