File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change 99def test_raise_on_missing_reader ():
1010 """Test the raise_on_missing_reader flag behavior."""
1111 print ("Testing LoadImage raise_on_missing_reader flag..." )
12-
12+
1313 # Test 1: Unknown reader with flag enabled - should raise OptionalImportError
1414 print ("Test 1: Unknown reader with raise_on_missing_reader=True" )
1515 try :
@@ -18,9 +18,9 @@ def test_raise_on_missing_reader():
1818 return False
1919 except OptionalImportError as e :
2020 print (f"PASS: Got expected OptionalImportError: { e } " )
21-
21+
2222 # Test 2: Unknown reader with flag disabled - should warn but not raise
23- print ("\n Test 2: Unknown reader with raise_on_missing_reader=False" )
23+ print ("\n Test 2: Unknown reader with raise_on_missing_reader=False" )
2424 try :
2525 with warnings .catch_warnings (record = True ) as w :
2626 warnings .simplefilter ("always" )
@@ -36,7 +36,7 @@ def test_raise_on_missing_reader():
3636 except Exception as e :
3737 print (f"FAIL: Unexpected error: { e } " )
3838 return False
39-
39+
4040 # Test 3: Valid reader - should work regardless of flag
4141 print ("\n Test 3: Valid reader (PILReader) with both flag settings" )
4242 try :
@@ -46,7 +46,7 @@ def test_raise_on_missing_reader():
4646 except Exception as e :
4747 print (f"FAIL: Unexpected error with valid reader: { e } " )
4848 return False
49-
49+
5050 print ("\n All tests passed!" )
5151 return True
5252
Original file line number Diff line number Diff line change @@ -452,7 +452,7 @@ def test_raise_on_missing_reader_flag(self):
452452 # Test with flag enabled - should raise exception for unknown reader name
453453 with self .assertRaises (OptionalImportError ):
454454 LoadImage (image_only = True , reader = "UnknownReaderName" , raise_on_missing_reader = True )
455-
455+
456456 # Test with flag disabled - should warn but not raise exception for unknown reader name
457457 # This should succeed and create the loader with fallback behavior
458458 with warnings .catch_warnings (record = True ) as w :
@@ -461,7 +461,7 @@ def test_raise_on_missing_reader_flag(self):
461461 self .assertIsInstance (loader_with_fallback , LoadImage )
462462 # Should have produced a warning about the unknown reader
463463 self .assertTrue (any ("Cannot find reader 'UnknownReaderName'" in str (warning .message ) for warning in w ))
464-
464+
465465 # The flag should work properly with valid readers too
466466 loader_with_flag = LoadImage (image_only = True , reader = "ITKReader" , raise_on_missing_reader = False )
467467 loader_without_flag = LoadImage (image_only = True , reader = "ITKReader" )
You can’t perform that action at this time.
0 commit comments