@@ -71,24 +71,26 @@ def test_invalid_file() -> None:
7171 SgiImagePlugin .SgiImageFile (invalid_file )
7272
7373
74- def test_write (tmp_path : Path ) -> None :
75- def roundtrip (img : Image .Image ) -> None :
76- out = tmp_path / "temp.sgi"
77- img .save (out , format = "sgi" )
74+ def roundtrip (img : Image .Image , tmp_path : Path ) -> None :
75+ out = tmp_path / "temp.sgi"
76+ img .save (out , format = "sgi" )
77+ assert_image_equal_tofile (img , out )
78+
79+ out = tmp_path / "fp.sgi"
80+ with open (out , "wb" ) as fp :
81+ img .save (fp )
7882 assert_image_equal_tofile (img , out )
7983
80- out = tmp_path / "fp.sgi"
81- with open (out , "wb" ) as fp :
82- img .save (fp )
83- assert_image_equal_tofile (img , out )
84+ assert not fp .closed
85+
8486
85- assert not fp .closed
87+ @pytest .mark .parametrize ("mode" , ("L" , "RGB" , "RGBA" ))
88+ def test_write (mode : str , tmp_path : Path ) -> None :
89+ roundtrip (hopper (mode ), tmp_path )
8690
87- for mode in ("L" , "RGB" , "RGBA" ):
88- roundtrip (hopper (mode ))
8991
90- # Test 1 dimension for an L mode image
91- roundtrip (Image .new ("L" , (10 , 1 )))
92+ def test_write_L_mode_1_dimension ( tmp_path : Path ) -> None :
93+ roundtrip (Image .new ("L" , (10 , 1 )), tmp_path )
9294
9395
9496def test_write16 (tmp_path : Path ) -> None :
0 commit comments