@@ -593,43 +593,41 @@ def test_map_array(self):
593593 del numpy
594594
595595
596- @unittest .skipIf (not pygame .HAVE_NEWBUF , "newbuf not implemented" )
597596@unittest .skipIf (IS_PYPY , "pypy having illegal instruction on mac" )
598597class PixelCopyTestWithArrayNewBuf (unittest .TestCase ):
599- if pygame .HAVE_NEWBUF :
600- from pygame .tests .test_utils import buftools
601-
602- class Array2D (buftools .Exporter ):
603- def __init__ (self , initializer ):
604- from ctypes import cast , POINTER , c_uint32
605-
606- Array2D = PixelCopyTestWithArrayNewBuf .Array2D
607- super ().__init__ ((3 , 5 ), format = "=I" , strides = (20 , 4 ))
608- self .content = cast (self .buf , POINTER (c_uint32 ))
609- for i , v in enumerate (initializer ):
610- self .content [i ] = v
611-
612- def __getitem__ (self , key ):
613- byte_index = key [0 ] * 5 + key [1 ]
614- if not (0 <= byte_index < 15 ):
615- raise IndexError ("%s is out of range" , key )
616- return self .content [byte_index ]
617-
618- class Array3D (buftools .Exporter ):
619- def __init__ (self , initializer ):
620- from ctypes import cast , POINTER , c_uint8
621-
622- Array3D = PixelCopyTestWithArrayNewBuf .Array3D
623- super ().__init__ ((3 , 5 , 3 ), format = "B" , strides = (20 , 4 , 1 ))
624- self .content = cast (self .buf , POINTER (c_uint8 ))
625- for i , v in enumerate (initializer ):
626- self .content [i ] = v
627-
628- def __getitem__ (self , key ):
629- byte_index = key [0 ] * 20 + key [1 ] * 4 + key [2 ]
630- if not (0 <= byte_index < 60 ):
631- raise IndexError ("%s is out of range" , key )
632- return self .content [byte_index ]
598+ from pygame .tests .test_utils import buftools
599+
600+ class Array2D (buftools .Exporter ):
601+ def __init__ (self , initializer ):
602+ from ctypes import cast , POINTER , c_uint32
603+
604+ Array2D = PixelCopyTestWithArrayNewBuf .Array2D
605+ super ().__init__ ((3 , 5 ), format = "=I" , strides = (20 , 4 ))
606+ self .content = cast (self .buf , POINTER (c_uint32 ))
607+ for i , v in enumerate (initializer ):
608+ self .content [i ] = v
609+
610+ def __getitem__ (self , key ):
611+ byte_index = key [0 ] * 5 + key [1 ]
612+ if not (0 <= byte_index < 15 ):
613+ raise IndexError ("%s is out of range" , key )
614+ return self .content [byte_index ]
615+
616+ class Array3D (buftools .Exporter ):
617+ def __init__ (self , initializer ):
618+ from ctypes import cast , POINTER , c_uint8
619+
620+ Array3D = PixelCopyTestWithArrayNewBuf .Array3D
621+ super ().__init__ ((3 , 5 , 3 ), format = "B" , strides = (20 , 4 , 1 ))
622+ self .content = cast (self .buf , POINTER (c_uint8 ))
623+ for i , v in enumerate (initializer ):
624+ self .content [i ] = v
625+
626+ def __getitem__ (self , key ):
627+ byte_index = key [0 ] * 20 + key [1 ] * 4 + key [2 ]
628+ if not (0 <= byte_index < 60 ):
629+ raise IndexError ("%s is out of range" , key )
630+ return self .content [byte_index ]
633631
634632 surface = pygame .Surface ((3 , 5 ), 0 , 32 )
635633
0 commit comments