@@ -176,24 +176,54 @@ def test_write_png_rgb():
176176 "hex_list, n_colors, expected_output" ,
177177 [
178178 (["#000000" , "#FFFFFF" ], 2 , ["#000000" , "#ffffff" ]),
179- (["#000000" , "#FFFFFF" ], 4 , [' #000000' , ' #545454' , ' #a9a9a9' , ' #ffffff' ]),
179+ (["#000000" , "#FFFFFF" ], 4 , [" #000000" , " #545454" , " #a9a9a9" , " #ffffff" ]),
180180 (["#FF0000" , "#00FF00" , "#0000FF" ], 3 , ["#ff0000" , "#00ff00" , "#0000ff" ]),
181- (["#FF0000" , "#00FF00" , "#0000FF" ], 4 , ['#ff0000' , '#55a900' , '#00aa54' , '#0000ff' ]),
182- (["#000000" , "#0000FF" ], 5 , ['#000000' , '#00003f' , '#00007f' , '#0000bf' , '#0000ff' ]),
183- (["#FFFFFF" , "#000000" ], 5 , ['#ffffff' , '#bfbfbf' , '#7f7f7f' , '#3f3f3f' , '#000000' ]),
184- (["#FF0000" , "#00FF00" , "#0000FF" ], 5 , ['#ff0000' , '#7f7f00' , '#00ff00' , '#007f7f' , '#0000ff' ]),
185- (["#FF0000" , "#00FF00" , "#0000FF" ], 7 , ['#ff0000' , '#aa5400' , '#55a900' , '#00ff00' , '#00aa54' , '#0055a9' , '#0000ff' ]),
186- ]
181+ (
182+ ["#FF0000" , "#00FF00" , "#0000FF" ],
183+ 4 ,
184+ ["#ff0000" , "#55a900" , "#00aa54" , "#0000ff" ],
185+ ),
186+ (
187+ ["#000000" , "#0000FF" ],
188+ 5 ,
189+ ["#000000" , "#00003f" , "#00007f" , "#0000bf" , "#0000ff" ],
190+ ),
191+ (
192+ ["#FFFFFF" , "#000000" ],
193+ 5 ,
194+ ["#ffffff" , "#bfbfbf" , "#7f7f7f" , "#3f3f3f" , "#000000" ],
195+ ),
196+ (
197+ ["#FF0000" , "#00FF00" , "#0000FF" ],
198+ 5 ,
199+ ["#ff0000" , "#7f7f00" , "#00ff00" , "#007f7f" , "#0000ff" ],
200+ ),
201+ (
202+ ["#FF0000" , "#00FF00" , "#0000FF" ],
203+ 7 ,
204+ [
205+ "#ff0000" ,
206+ "#aa5400" ,
207+ "#55a900" ,
208+ "#00ff00" ,
209+ "#00aa54" ,
210+ "#0055a9" ,
211+ "#0000ff" ,
212+ ],
213+ ),
214+ ],
187215)
188- def test_linear_gradient (hex_list : List [str ], n_colors : int , expected_output : List [str ]):
216+ def test_linear_gradient (
217+ hex_list : List [str ], n_colors : int , expected_output : List [str ]
218+ ):
189219 result = ut .linear_gradient (hex_list , n_colors )
190220 assert len (result ) == len (expected_output ), "Output length mismatch"
191221
192222 # because we rewrote this function, we allow a difference of 1 between the old and the new version
193223 tolerance = 1
194224 for actual , expected in zip (result , expected_output ):
195- r1 , g1 , b1 = (int (actual [i : i + 2 ], 16 ) for i in (1 , 3 , 5 ))
196- r2 , g2 , b2 = (int (expected [i : i + 2 ], 16 ) for i in (1 , 3 , 5 ))
225+ r1 , g1 , b1 = (int (actual [i : i + 2 ], 16 ) for i in (1 , 3 , 5 ))
226+ r2 , g2 , b2 = (int (expected [i : i + 2 ], 16 ) for i in (1 , 3 , 5 ))
197227 if not all (abs (a - b ) <= tolerance for a , b in zip ((r1 , g1 , b1 ), (r2 , g2 , b2 ))):
198228 # to get a nice output, assert the full array when we spot a failure
199229 assert result == expected_output
0 commit comments