Skip to content

Commit

Permalink
TESTS Avoid using buffer api on unsupported types for 3.7 and 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
mcfletch committed Sep 29, 2024
1 parent db9f419 commit 459421b
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions tests/test_arraydatatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,31 +220,39 @@ def test_bytearray_support(self):
def test_buffer_api_basic(self):
import array as silly_array

structures = [
(b'this and that', 13, 1, True, 1, b'B', [13], [1]),
]
structures = []
if sys.version_info[:2] >= (3, 9):
structures.append(
(b'this and that', 13, 1, True, 1, b'B', [13], [1]),
)

if sys.version_info[:2] >= (2, 7):
# GH#92 Big-endian hosts report different formats because yeah, obviously
if sys.byteorder == 'little': # x86 cases
int_formats = [b'(3)<i', b'(3)<l', b'<i', b'<l']
else:
int_formats = [b'(3)>i', b'(3)>l', b'>i', b'>l']

structures.append(
# on Python 3.4 we do *not* get the (3) prefix :(
(
(GLint * 3)(1, 2, 3),
12,
4,
False,
1,
int_formats,
[3],
None,
),
)
if sys.version_info[:2] not in [(3, 8), (3, 7)]:

if sys.version_info[:2] >= (3, 0):
structures.append(
# on Python 3.4 we do *not* get the (3) prefix :(
(
(GLint * 3)(1, 2, 3),
12,
4,
False,
1,
int_formats,
[3],
None,
),
)

if sys.version_info[:2] >= (3, 0) and sys.version_info[:2] not in [
(3, 8),
(3, 7),
]:
# only supports buffer protocol in 3.x
structures.extend(
[
Expand All @@ -261,7 +269,8 @@ def test_buffer_api_basic(self):
]
)
try:
structures.append((memoryview(b'this'), 4, 1, True, 1, b'B', [4], [1]))
if sys.version_info[:2] not in [(3, 8), (3, 7)]:
structures.append((memoryview(b'this'), 4, 1, True, 1, b'B', [4], [1]))
except NameError:
# Python 2.6 doesn't have memory view
pass
Expand Down

0 comments on commit 459421b

Please sign in to comment.