1212# Hardcoded expected quantity
1313# These values were obtained using the following scratch script:
1414# arr = tiff.imread("docs/examples/KFe2As2-00838.tif")
15- # arr.mean()
15+ # arr.mean(), arr.shape
1616
1717
1818load_image_param = [
1919 # case 1: just filename of file in current directory.
2020 # expect function loads tiff file from cwd
21- ( "KFe2As2-00838.tif" , np . float32 ( 2595.7087 )) ,
21+ "KFe2As2-00838.tif" ,
2222 # case 2: absolute file path to file in another directory.
2323 # expect file is found and correctly read.
24- ( "home_dir/KFe2As2-00838.tif" , np . float32 ( 2595.7087 )) ,
24+ "home_dir/KFe2As2-00838.tif" ,
2525 # case 3: relative file path to file in another directory.
2626 # expect file is found and correctly read
27- ( "./KFe2As2-00838.tif" , np . float32 ( 2595.7087 )) ,
27+ "./KFe2As2-00838.tif" ,
2828 # case 4: non-existent file that incurred by mistype.
29- ( "nonexistent_file.tif" , FileNotFoundError ) ,
29+ "nonexistent_file.tif" ,
3030]
3131
3232
33- @pytest .mark .parametrize ("file_name, expected " , load_image_param )
34- def test_load_image (file_name , expected , user_filesystem ):
33+ @pytest .mark .parametrize ("file_name" , load_image_param )
34+ def test_load_image (file_name , user_filesystem ):
3535 home_dir = user_filesystem ["home" ]
3636 cwd_dir = user_filesystem ["cwd" ]
3737 os .chdir (cwd_dir )
@@ -46,8 +46,11 @@ def test_load_image(file_name, expected, user_filesystem):
4646 "Cfg" , (), {"fliphorizontal" : False , "flipvertical" : False }
4747 )()
4848 loader = LoadImage (cfg )
49- actual = loader .load_image (file_name ).mean ()
50- assert actual == expected
49+ actual = loader .load_image (file_name )
50+ expected_mean = np .float32 (2595.7087 )
51+ expected_shape = (2048 , 2048 )
52+ assert actual .shape == expected_shape
53+ assert actual .mean () == expected_mean
5154 except FileNotFoundError :
5255 pytest .raises (
5356 FileNotFoundError ,
0 commit comments