@@ -105,91 +105,68 @@ def test_wrong_args(self) -> None:
105105 with pytest .raises (TypeError ):
106106 im .im .color_lut_3d ("RGB" , Image .Resampling .BILINEAR , 3 , 2 , 2 , 2 , 16 )
107107
108- def test_correct_args (self ) -> None :
108+ @pytest .mark .parametrize (
109+ "lut_mode, table_channels, table_size" ,
110+ [
111+ ("RGB" , 3 , 3 ),
112+ ("CMYK" , 4 , 3 ),
113+ ("RGB" , 3 , (2 , 3 , 3 )),
114+ ("RGB" , 3 , (65 , 3 , 3 )),
115+ ("RGB" , 3 , (3 , 65 , 3 )),
116+ ("RGB" , 3 , (2 , 3 , 65 )),
117+ ],
118+ )
119+ def test_correct_args (
120+ self , lut_mode : str , table_channels : int , table_size : int | tuple [int , int , int ]
121+ ) -> None :
109122 im = Image .new ("RGB" , (10 , 10 ), 0 )
110-
111- im .im .color_lut_3d (
112- "RGB" , Image .Resampling .BILINEAR , * self .generate_identity_table (3 , 3 )
113- )
114-
115- im .im .color_lut_3d (
116- "CMYK" , Image .Resampling .BILINEAR , * self .generate_identity_table (4 , 3 )
117- )
118-
123+ assert im .im is not None
119124 im .im .color_lut_3d (
120- "RGB" ,
125+ lut_mode ,
121126 Image .Resampling .BILINEAR ,
122- * self .generate_identity_table (3 , (2 , 3 , 3 )),
123- )
124-
125- im .im .color_lut_3d (
126- "RGB" ,
127- Image .Resampling .BILINEAR ,
128- * self .generate_identity_table (3 , (65 , 3 , 3 )),
129- )
130-
131- im .im .color_lut_3d (
132- "RGB" ,
133- Image .Resampling .BILINEAR ,
134- * self .generate_identity_table (3 , (3 , 65 , 3 )),
135- )
136-
137- im .im .color_lut_3d (
138- "RGB" ,
139- Image .Resampling .BILINEAR ,
140- * self .generate_identity_table (3 , (3 , 3 , 65 )),
141- )
142-
143- def test_wrong_mode (self ) -> None :
144- with pytest .raises (ValueError , match = "wrong mode" ):
145- im = Image .new ("L" , (10 , 10 ), 0 )
146- im .im .color_lut_3d (
147- "RGB" , Image .Resampling .BILINEAR , * self .generate_identity_table (3 , 3 )
148- )
149-
150- with pytest .raises (ValueError , match = "wrong mode" ):
151- im = Image .new ("RGB" , (10 , 10 ), 0 )
152- im .im .color_lut_3d (
153- "L" , Image .Resampling .BILINEAR , * self .generate_identity_table (3 , 3 )
154- )
155-
156- with pytest .raises (ValueError , match = "wrong mode" ):
157- im = Image .new ("L" , (10 , 10 ), 0 )
158- im .im .color_lut_3d (
159- "L" , Image .Resampling .BILINEAR , * self .generate_identity_table (3 , 3 )
160- )
161-
162- with pytest .raises (ValueError , match = "wrong mode" ):
163- im = Image .new ("RGB" , (10 , 10 ), 0 )
164- im .im .color_lut_3d (
165- "RGBA" , Image .Resampling .BILINEAR , * self .generate_identity_table (3 , 3 )
166- )
167-
127+ * self .generate_identity_table (table_channels , table_size ),
128+ )
129+
130+ @pytest .mark .parametrize (
131+ "image_mode, lut_mode, table_channels, table_size" ,
132+ [
133+ ("L" , "RGB" , 3 , 3 ),
134+ ("RGB" , "L" , 3 , 3 ),
135+ ("L" , "L" , 3 , 3 ),
136+ ("RGB" , "RGBA" , 3 , 3 ),
137+ ("RGB" , "RGB" , 4 , 3 ),
138+ ],
139+ )
140+ def test_wrong_mode (
141+ self , image_mode : str , lut_mode : str , table_channels : int , table_size : int
142+ ) -> None :
168143 with pytest .raises (ValueError , match = "wrong mode" ):
169- im = Image .new ("RGB" , (10 , 10 ), 0 )
144+ im = Image .new (image_mode , (10 , 10 ), 0 )
145+ assert im .im is not None
170146 im .im .color_lut_3d (
171- "RGB" , Image .Resampling .BILINEAR , * self .generate_identity_table (4 , 3 )
147+ lut_mode ,
148+ Image .Resampling .BILINEAR ,
149+ * self .generate_identity_table (table_channels , table_size ),
172150 )
173151
174- def test_correct_mode (self ) -> None :
175- im = Image .new ("RGBA" , (10 , 10 ), 0 )
176- im .im .color_lut_3d (
177- "RGBA" , Image .Resampling .BILINEAR , * self .generate_identity_table (3 , 3 )
178- )
179-
180- im = Image .new ("RGBA" , (10 , 10 ), 0 )
152+ @pytest .mark .parametrize (
153+ "image_mode, lut_mode, table_channels, table_size" ,
154+ [
155+ ("RGBA" , "RGBA" , 3 , 3 ),
156+ ("RGBA" , "RGBA" , 4 , 3 ),
157+ ("RGB" , "HSV" , 3 , 3 ),
158+ ("RGB" , "RGBA" , 4 , 3 ),
159+ ],
160+ )
161+ def test_correct_mode (
162+ self , image_mode : str , lut_mode : str , table_channels : int , table_size : int
163+ ) -> None :
164+ im = Image .new (image_mode , (10 , 10 ), 0 )
165+ assert im .im is not None
181166 im .im .color_lut_3d (
182- "RGBA" , Image .Resampling .BILINEAR , * self .generate_identity_table (4 , 3 )
183- )
184-
185- im = Image .new ("RGB" , (10 , 10 ), 0 )
186- im .im .color_lut_3d (
187- "HSV" , Image .Resampling .BILINEAR , * self .generate_identity_table (3 , 3 )
188- )
189-
190- im = Image .new ("RGB" , (10 , 10 ), 0 )
191- im .im .color_lut_3d (
192- "RGBA" , Image .Resampling .BILINEAR , * self .generate_identity_table (4 , 3 )
167+ lut_mode ,
168+ Image .Resampling .BILINEAR ,
169+ * self .generate_identity_table (table_channels , table_size ),
193170 )
194171
195172 def test_identities (self ) -> None :
0 commit comments