88from .helper import (
99 assert_image_equal ,
1010 assert_image_similar ,
11+ assert_image_similar_tofile ,
1112 is_big_endian ,
1213 skip_unless_feature ,
1314)
@@ -62,9 +63,7 @@ def test_invalid_file():
6263def test_bytesio ():
6364 with open ("Tests/images/test-card-lossless.jp2" , "rb" ) as f :
6465 data = BytesIO (f .read ())
65- with Image .open (data ) as im :
66- im .load ()
67- assert_image_similar (im , test_card , 1.0e-3 )
66+ assert_image_similar_tofile (test_card , data , 1.0e-3 )
6867
6968
7069# These two test pre-written JPEG 2000 files that were not written with
@@ -80,9 +79,9 @@ def test_lossless(tmp_path):
8079
8180
8281def test_lossy_tiled ():
83- with Image . open ( "Tests/images/test-card-lossy-tiled.jp2" ) as im :
84- im . load ()
85- assert_image_similar ( im , test_card , 2.0 )
82+ assert_image_similar_tofile (
83+ test_card , "Tests/images/test-card-lossy-tiled.jp2" , 2.0
84+ )
8685
8786
8887def test_lossless_rt ():
@@ -193,15 +192,13 @@ def test_16bit_monochrome_has_correct_mode():
193192@pytest .mark .xfail (is_big_endian (), reason = "Fails on big-endian" )
194193def test_16bit_monochrome_jp2_like_tiff ():
195194 with Image .open ("Tests/images/16bit.cropped.tif" ) as tiff_16bit :
196- with Image .open ("Tests/images/16bit.cropped.jp2" ) as jp2 :
197- assert_image_similar (jp2 , tiff_16bit , 1e-3 )
195+ assert_image_similar_tofile (tiff_16bit , "Tests/images/16bit.cropped.jp2" , 1e-3 )
198196
199197
200198@pytest .mark .xfail (is_big_endian (), reason = "Fails on big-endian" )
201199def test_16bit_monochrome_j2k_like_tiff ():
202200 with Image .open ("Tests/images/16bit.cropped.tif" ) as tiff_16bit :
203- with Image .open ("Tests/images/16bit.cropped.j2k" ) as j2k :
204- assert_image_similar (j2k , tiff_16bit , 1e-3 )
201+ assert_image_similar_tofile (tiff_16bit , "Tests/images/16bit.cropped.j2k" , 1e-3 )
205202
206203
207204def test_16bit_j2k_roundtrips ():
0 commit comments