@@ -232,11 +232,13 @@ def test_p_putpixel_rgb_rgba(self, mode, color):
232232 assert im .convert ("RGBA" ).getpixel ((0 , 0 )) == (255 , 0 , 0 , alpha )
233233
234234
235+ @pytest .mark .filterwarnings ("ignore::DeprecationWarning" )
235236@pytest .mark .skipif (cffi is None , reason = "No CFFI" )
236237class TestCffiPutPixel (TestImagePutPixel ):
237238 _need_cffi_access = True
238239
239240
241+ @pytest .mark .filterwarnings ("ignore::DeprecationWarning" )
240242@pytest .mark .skipif (cffi is None , reason = "No CFFI" )
241243class TestCffiGetPixel (TestImageGetPixel ):
242244 _need_cffi_access = True
@@ -252,7 +254,8 @@ def _test_get_access(self, im):
252254 Using private interfaces, forcing a capi access and
253255 a pyaccess for the same image"""
254256 caccess = im .im .pixel_access (False )
255- access = PyAccess .new (im , False )
257+ with pytest .warns (DeprecationWarning ):
258+ access = PyAccess .new (im , False )
256259
257260 w , h = im .size
258261 for x in range (0 , w , 10 ):
@@ -264,20 +267,16 @@ def _test_get_access(self, im):
264267 access [(access .xsize + 1 , access .ysize + 1 )]
265268
266269 def test_get_vs_c (self ):
267- rgb = hopper ("RGB" )
268- rgb .load ()
269- self ._test_get_access (rgb )
270- self ._test_get_access (hopper ("RGBA" ))
271- self ._test_get_access (hopper ("L" ))
272- self ._test_get_access (hopper ("LA" ))
273- self ._test_get_access (hopper ("1" ))
274- self ._test_get_access (hopper ("P" ))
275- # self._test_get_access(hopper('PA')) # PA -- how do I make a PA image?
276- self ._test_get_access (hopper ("F" ))
270+ with pytest .warns (DeprecationWarning ):
271+ rgb = hopper ("RGB" )
272+ rgb .load ()
273+ self ._test_get_access (rgb )
274+ for mode in ("RGBA" , "L" , "LA" , "1" , "P" , "F" ):
275+ self ._test_get_access (hopper (mode ))
277276
278- for mode in ("I;16" , "I;16L" , "I;16B" , "I;16N" , "I" ):
279- im = Image .new (mode , (10 , 10 ), 40000 )
280- self ._test_get_access (im )
277+ for mode in ("I;16" , "I;16L" , "I;16B" , "I;16N" , "I" ):
278+ im = Image .new (mode , (10 , 10 ), 40000 )
279+ self ._test_get_access (im )
281280
282281 # These don't actually appear to be modes that I can actually make,
283282 # as unpack sets them directly into the I mode.
@@ -292,7 +291,8 @@ def _test_set_access(self, im, color):
292291 Using private interfaces, forcing a capi access and
293292 a pyaccess for the same image"""
294293 caccess = im .im .pixel_access (False )
295- access = PyAccess .new (im , False )
294+ with pytest .warns (DeprecationWarning ):
295+ access = PyAccess .new (im , False )
296296
297297 w , h = im .size
298298 for x in range (0 , w , 10 ):
@@ -301,13 +301,15 @@ def _test_set_access(self, im, color):
301301 assert color == caccess [(x , y )]
302302
303303 # Attempt to set the value on a read-only image
304- access = PyAccess .new (im , True )
304+ with pytest .warns (DeprecationWarning ):
305+ access = PyAccess .new (im , True )
305306 with pytest .raises (ValueError ):
306307 access [(0 , 0 )] = color
307308
308309 def test_set_vs_c (self ):
309310 rgb = hopper ("RGB" )
310- rgb .load ()
311+ with pytest .warns (DeprecationWarning ):
312+ rgb .load ()
311313 self ._test_set_access (rgb , (255 , 128 , 0 ))
312314 self ._test_set_access (hopper ("RGBA" ), (255 , 192 , 128 , 0 ))
313315 self ._test_set_access (hopper ("L" ), 128 )
@@ -326,6 +328,7 @@ def test_set_vs_c(self):
326328 # im = Image.new('I;32B', (10, 10), 2**10)
327329 # self._test_set_access(im, 2**13-1)
328330
331+ @pytest .mark .filterwarnings ("ignore::DeprecationWarning" )
329332 def test_not_implemented (self ):
330333 assert PyAccess .new (hopper ("BGR;15" )) is None
331334
@@ -335,7 +338,8 @@ def test_reference_counting(self):
335338
336339 for _ in range (10 ):
337340 # Do not save references to the image, only to the access object
338- px = Image .new ("L" , (size , 1 ), 0 ).load ()
341+ with pytest .warns (DeprecationWarning ):
342+ px = Image .new ("L" , (size , 1 ), 0 ).load ()
339343 for i in range (size ):
340344 # pixels can contain garbage if image is released
341345 assert px [i , 0 ] == 0
@@ -344,12 +348,13 @@ def test_reference_counting(self):
344348 def test_p_putpixel_rgb_rgba (self , mode ):
345349 for color in ((255 , 0 , 0 ), (255 , 0 , 0 , 127 if mode == "PA" else 255 )):
346350 im = Image .new (mode , (1 , 1 ))
347- access = PyAccess .new (im , False )
348- access .putpixel ((0 , 0 ), color )
351+ with pytest .warns (DeprecationWarning ):
352+ access = PyAccess .new (im , False )
353+ access .putpixel ((0 , 0 ), color )
349354
350- if len (color ) == 3 :
351- color += (255 ,)
352- assert im .convert ("RGBA" ).getpixel ((0 , 0 )) == color
355+ if len (color ) == 3 :
356+ color += (255 ,)
357+ assert im .convert ("RGBA" ).getpixel ((0 , 0 )) == color
353358
354359
355360class TestImagePutPixelError (AccessTest ):
0 commit comments