File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -528,29 +528,28 @@ def test_unspecified_reader_falls_back_silently(self):
528528 # Force the fallback path by simulating missing optional dependencies.
529529 # Patch the constructor to raise OptionalImportError for some readers,
530530 # then verify LoadImage still instantiates and logs warnings.
531- import logging
532531 from monai .utils import OptionalImportError
533-
532+
534533 # Patch SUPPORTED_READERS entries to raise OptionalImportError
535534 # This simulates optional packages not being installed
536535 original_readers = {}
537536 from monai .transforms .io .array import SUPPORTED_READERS
538-
537+
539538 # Patch a few readers to fail (e.g., ITKReader)
540539 try :
541540 original_itk = SUPPORTED_READERS .get ("itk" )
542-
541+
543542 def failing_reader (* args , ** kwargs ):
544543 raise OptionalImportError ("itk not installed" )
545-
544+
546545 # Temporarily replace ITKReader with a failing version
547546 SUPPORTED_READERS ["itk" ] = failing_reader
548-
547+
549548 # Capture log output to verify warn-and-skip was invoked
550549 with self .assertLogs ("LoadImage" , level = "DEBUG" ) as cm :
551550 loader = LoadImage ()
552551 self .assertIsInstance (loader , LoadImage )
553-
552+
554553 # Verify we got the expected debug log about skipping the missing reader
555554 self .assertTrue (any ("not installed" in msg for msg in cm .output ),
556555 f"Expected 'not installed' in debug logs, got: { cm .output } " )
You can’t perform that action at this time.
0 commit comments