Skip to content

Commit 1ceb2e0

Browse files
committed
Remove HAVE_NEWBUF checks in tests
1 parent 06572ce commit 1ceb2e0

File tree

9 files changed

+36
-58
lines changed

9 files changed

+36
-58
lines changed

test/base_test.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ def get__array_struct__(self):
193193
o = Exporter(shape, typechar, itemsize)
194194
self.assertEqual(getrefcount(o.__array_struct__), 1)
195195

196-
if pygame.HAVE_NEWBUF:
197-
from pygame.tests.test_utils import buftools
196+
from pygame.tests.test_utils import buftools
198197

199198
def NEWBUF_assertSame(self, proxy, exp):
200199
buftools = self.buftools
@@ -209,7 +208,6 @@ def NEWBUF_assertSame(self, proxy, exp):
209208
self.assertEqual(imp.strides, exp.strides)
210209
self.assertTrue(imp.suboffsets is None)
211210

212-
@unittest.skipIf(not pygame.HAVE_NEWBUF, "newbuf not implemented")
213211
@unittest.skipIf(IS_PYPY, "pypy no likey")
214212
def test_newbuf(self):
215213
from pygame.bufferproxy import BufferProxy
@@ -250,7 +248,6 @@ def test_newbuf(self):
250248
v = BufferProxy(o)
251249
self.NEWBUF_assertSame(v, o)
252250

253-
@unittest.skipIf(not pygame.HAVE_NEWBUF, "newbuf not implemented")
254251
def test_bad_format(self):
255252
from pygame.bufferproxy import BufferProxy
256253
from pygame.newbuffer import BufferMixin
@@ -280,7 +277,6 @@ def test_bad_format(self):
280277
b = BufferProxy(exp)
281278
self.assertRaises(ValueError, Importer, b, PyBUF_FORMAT)
282279

283-
@unittest.skipIf(not pygame.HAVE_NEWBUF, "newbuf not implemented")
284280
@unittest.skipIf(IS_PYPY, "fails on pypy")
285281
def test_PgDict_AsBuffer_PyBUF_flags(self):
286282
from pygame.bufferproxy import BufferProxy
@@ -382,7 +378,7 @@ def test_PgDict_AsBuffer_PyBUF_flags(self):
382378
self.assertEqual(b.buf, 1000000)
383379
self.assertRaises(BufferError, Importer, a, buftools.PyBUF_FULL)
384380

385-
@unittest.skipIf(IS_PYPY or (not pygame.HAVE_NEWBUF), "newbuf with ctypes")
381+
@unittest.skipIf(IS_PYPY, "newbuf with ctypes")
386382
def test_PgObject_AsBuffer_PyBUF_flags(self):
387383
from pygame.bufferproxy import BufferProxy
388384
import ctypes

test/bufferproxy_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ def __repr__(self):
255255
self.assertEqual(r[:2], "*<")
256256
self.assertEqual(r[-2:], ">*")
257257

258-
@unittest.skipIf(not pygame.HAVE_NEWBUF, "newbuf not implemented")
259258
def NEWBUF_test_newbuf(self):
260259
from ctypes import string_at
261260

test/color_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,6 @@ def test_arraystruct(self):
10881088
for j in range(i):
10891089
self.assertEqual(data[j], c[j])
10901090

1091-
@unittest.skipIf(not pygame.HAVE_NEWBUF, "newbuf not implemented")
10921091
def test_newbuf(self):
10931092
from pygame.tests.test_utils import buftools
10941093
from ctypes import cast, POINTER, c_uint8

test/freetype_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,6 @@ def test_freetype_Font_bgcolor(self):
12461246

12471247
self.assertRaises(AttributeError, setattr, f, "bgcolor", None)
12481248

1249-
@unittest.skipIf(not pygame.HAVE_NEWBUF, "newbuf not implemented")
12501249
@unittest.skipIf(IS_PYPY, "pypy no likey")
12511250
def test_newbuf(self):
12521251
from pygame.tests.test_utils import buftools

test/mixer_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,11 @@ def test_array_interface(self):
359359
self.assertEqual(d["strides"], (2,))
360360
self.assertEqual(d["data"], (snd._samples_address, False))
361361

362-
@unittest.skipIf(not pygame.HAVE_NEWBUF, "newbuf not implemented")
363362
@unittest.skipIf(IS_PYPY, "pypy no likey")
364363
def test_newbuf__one_channel(self):
365364
mixer.init(22050, -16, 1)
366365
self._NEWBUF_export_check()
367366

368-
@unittest.skipIf(not pygame.HAVE_NEWBUF, "newbuf not implemented")
369367
@unittest.skipIf(IS_PYPY, "pypy no likey")
370368
def test_newbuf__twho_channel(self):
371369
mixer.init(22050, -16, 2)

test/pixelarray_test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,11 +1450,9 @@ def test_slicing(self):
14501450
self.assert_surfaces_equal(sf3, sf2)
14511451

14521452

1453-
@unittest.skipIf(not pygame.HAVE_NEWBUF, "newbuf not implemented")
14541453
@unittest.skipIf(IS_PYPY, "pypy having issues")
14551454
class PixelArrayNewBufferTest(unittest.TestCase, TestMixin):
1456-
if pygame.HAVE_NEWBUF:
1457-
from pygame.tests.test_utils import buftools
1455+
from pygame.tests.test_utils import buftools
14581456

14591457
bitsize_to_format = {8: "B", 16: "=H", 24: "3x", 32: "=I"}
14601458

test/pixelcopy_test.py

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -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")
598597
class 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

test/surface_test.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3001,7 +3001,6 @@ def test_array_interface_rgb(self):
30013001
s = pygame.Surface((4, 2), 0, 32)
30023002
self._check_interface_rgba(s, plane)
30033003

3004-
@unittest.skipIf(not pygame.HAVE_NEWBUF, "newbuf not implemented")
30053004
def test_newbuf_PyBUF_flags_bytes(self):
30063005
from pygame.tests.test_utils import buftools
30073006

@@ -3061,7 +3060,6 @@ def test_newbuf_PyBUF_flags_bytes(self):
30613060
self.assertEqual(b.ndim, 1)
30623061
self.assertEqual(b.strides, (1,))
30633062

3064-
@unittest.skipIf(not pygame.HAVE_NEWBUF, "newbuf not implemented")
30653063
def test_newbuf_PyBUF_flags_0D(self):
30663064
# This is the same handler as used by get_buffer(), so just
30673065
# confirm that it succeeds for one case.
@@ -3081,7 +3079,6 @@ def test_newbuf_PyBUF_flags_0D(self):
30813079
self.assertFalse(b.readonly)
30823080
self.assertEqual(b.buf, s._pixels_address)
30833081

3084-
@unittest.skipIf(not pygame.HAVE_NEWBUF, "newbuf not implemented")
30853082
def test_newbuf_PyBUF_flags_1D(self):
30863083
from pygame.tests.test_utils import buftools
30873084

@@ -3120,7 +3117,6 @@ def test_newbuf_PyBUF_flags_1D(self):
31203117
self.assertTrue(b.format is None)
31213118
self.assertEqual(b.strides, (s.get_bytesize(),))
31223119

3123-
@unittest.skipIf(not pygame.HAVE_NEWBUF, "newbuf not implemented")
31243120
def test_newbuf_PyBUF_flags_2D(self):
31253121
from pygame.tests.test_utils import buftools
31263122

@@ -3191,7 +3187,6 @@ def test_newbuf_PyBUF_flags_2D(self):
31913187
self.assertRaises(BufferError, Importer, a, buftools.PyBUF_F_CONTIGUOUS)
31923188
self.assertRaises(BufferError, Importer, a, buftools.PyBUF_ANY_CONTIGUOUS)
31933189

3194-
@unittest.skipIf(not pygame.HAVE_NEWBUF, "newbuf not implemented")
31953190
def test_newbuf_PyBUF_flags_3D(self):
31963191
from pygame.tests.test_utils import buftools
31973192

@@ -3242,7 +3237,6 @@ def test_newbuf_PyBUF_flags_3D(self):
32423237
self.assertRaises(BufferError, Importer, a, buftools.PyBUF_F_CONTIGUOUS)
32433238
self.assertRaises(BufferError, Importer, a, buftools.PyBUF_ANY_CONTIGUOUS)
32443239

3245-
@unittest.skipIf(not pygame.HAVE_NEWBUF, "newbuf not implemented")
32463240
def test_newbuf_PyBUF_flags_rgba(self):
32473241
# All color plane views are handled by the same routine,
32483242
# so only one plane need be checked.

test/test_utils/buftools.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
"""
2222
import pygame
2323

24-
if not pygame.HAVE_NEWBUF:
25-
emsg = "This Pygame build does not support the new buffer protocol"
26-
raise ImportError(emsg)
2724
import pygame.newbuffer
2825
from pygame.newbuffer import (
2926
PyBUF_SIMPLE,

0 commit comments

Comments
 (0)